# Gatling multiple scenarios with multiple concurrent users

**URL:** <https://community.gatling.io/t/gatling-multiple-scenarios-with-multiple-concurrent-users/5892>\
**Category:** Gatling (Open-Source)\
**Created:** [November 16, 2020, 1:59pm UTC](https://community.gatling.io/t/gatling-multiple-scenarios-with-multiple-concurrent-users/5892 "2020-11-16T13:59:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachinb](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@sachinb](https://community.gatling.io/u/sachinb)\
**Post date:** [November 16, 2020, 1:59pm UTC](https://community.gatling.io/t/gatling-multiple-scenarios-with-multiple-concurrent-users/5892/1 "2020-11-16T13:59:14Z")

</div>

Hi team,

I am new to Gatling and Gatling frontline. I have a simulation with 4 different objects defined. I need to run scenario a and b with 1 concurrent user and scenario c and d with 1000 concurrent users . is there a way i can do that in a single simulation? I have tried the code below but it runs the simulation for 1 users only, is there a better way to run these kind of simulations.  
Scenario explanation: I want the Object A and B to run for 1 user , then get the Install and appId and run the other two scenarios for 100 users.

Note: I am also passing two ID’s from scenario A and B to Scenario C,D.

Test code:

val appUsers = 1  
val eventUsers = 100

var installId= " "  
var AppId = " "

object A {  
val a = exec (http(“Scenario A”)  
.get("/something"))  
.check(bodyString.transform(str =\> str.replace(""", “”)).saveAs(“installId”))

.exec((session =\> {  
installId = session(“installId”).as[String].trim  
session  
}))

}

object B {  
val ab= exec (http(“Scenario B”)  
.get("/something")  
.check(bodyString.transform(str =\> str.replace(""", “”)).saveAs(“AppID”))

.exec((session =\> {  
installId = session(“installId”).as[String].trim  
session

}))  
}

object C {  
.exec(\_.set(“installId”, installId))

val c = exec (http(“Scenario C”)  
.get("/something/${installId}"))  
}

object D {  
val d = exec(\_.set(“AppID”, AppId))  
.exec (http(“Scenario D”)  
.get("/something/${AppId}"))  
}

val scenario1 = scenario(" A and B").exec(A.a , B.b)  
val scenario2 = scenario(“C and D”).exec(C.c , D.d)

setUp(  
_scenario1_.inject(rampConcurrentUsers(0) to appUsers during (appRunTime seconds)),  
_scenario2_inject(nothingFor(20 seconds) , rampUsers(eventUsers) during (eventUsers seconds))  
).protocols(httpProtocol)

Thanks,  
Sachin Balusu

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [November 16, 2020, 5:17pm UTC](https://community.gatling.io/t/gatling-multiple-scenarios-with-multiple-concurrent-users/5892/2 "2020-11-16T17:17:51Z")

</div>

No idea what your problem is. Have you read the doc? [https://gatling.io/docs/current/general/simulation\_setup/#closed-model](https://gatling.io/docs/current/general/simulation_setup/#closed-model)

_scenario1_.inject(constantConcurrentUsers(1) during (100 seconds)),  
_scenario2_inject(constantConcurrentUsers(1000) during (100 seconds))
