# Inject users in stages

**URL:** <https://community.gatling.io/t/inject-users-in-stages/7493>\
**Category:** Gatling (Open-Source)\
**Created:** [January 9, 2023, 10:02am UTC](https://community.gatling.io/t/inject-users-in-stages/7493 "2023-01-09T10:02:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurG](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@ArthurG](https://community.gatling.io/u/ArthurG)\
**Post date:** [January 9, 2023, 10:02am UTC](https://community.gatling.io/t/inject-users-in-stages/7493/1 "2023-01-09T10:02:24Z")

</div>

Hi,

I want to inject virtual users like this:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/3/3dce4a014431080cba6ea7c025dfb46dc1a81b34.png)

This is possible ?  
I tried with this setup but it works halfway:  
incrementUsersPerSec(1)  
.times(5)  
.eachLevelLasting(10)  
.separatedByRampsLasting(5)  
.startingFrom(10)  
Thank you for your answer !

AG

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [January 9, 2023, 10:21am UTC](https://community.gatling.io/t/inject-users-in-stages/7493/2 "2023-01-09T10:21:58Z")

</div>

Hi @ArthurG,

Did you read the different options in [Open Model Injection](https://gatling.io/docs/gatling/reference/current/core/injection/#open-model)?

If I understand your schema, you want a ramp of users per second, then stay, then a ramp down.

So, if your scenario is called `scn`:

```java

int rampUpDuration = 5;
int flatDuration = 60;
int rampDownDuration = 2;
int maxUsersPerSecond = 10;

scn.injectOpen(
    rampUsersPerSec(0).to(maxUsersPerSecond).during(rampUpDuration),
    constantUsersPerSec(maxUsersPerSecond).during(flatDuration),
    rampUsersPerSec(maxUsersPerSecond).to(0).during(rampDownDuration)
  )

```

Does it help?

Cheers!

---

<div class="post-metadata">

**Author:** ![ArthurG](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@ArthurG](https://community.gatling.io/u/ArthurG)\
**Post date:** [January 9, 2023, 10:55am UTC](https://community.gatling.io/t/inject-users-in-stages/7493/3 "2023-01-09T10:55:00Z")

</div>

You are very kind to help me  
Ok sorry I got my image wrong. This is the style of curve I would like to get for my active users:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/7/78f399103a5bee32542c960d8e14fafbf9426c25.png)

I tried with the functions you suggested with different values, like this:

```
private val rampUpDuration = 5;
private val flatDuration = 10;
private val step1 = 1;
private val step2 = 2;
private val step3 = 3;

rampUsersPerSec(0).to(step1).during(rampUpDuration),
constantUsersPerSec(step1).during(flatDuration),
rampUsersPerSec(step1).to(step2).during(rampUpDuration),
constantUsersPerSec(step2).during(flatDuration),
rampUsersPerSec(step2).to(step3).during(rampUpDuration)

```

But the resulting curve is as follows:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/3/3027c9195a1adb1f46d91fbb91803e20ebc46122.png)

Thanks in advance for your help.

---

<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:** [January 9, 2023, 10:58am UTC](https://community.gatling.io/t/inject-users-in-stages/7493/4 "2023-01-09T10:58:39Z")

</div>

@ArthurG You’re confusing arrival rate, active users and concurrent users. You should read the documentation about injection profiles: [Gatling - Injection](https://gatling.io/docs/gatling/reference/current/core/injection/).

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [February 8, 2023, 10:59am UTC](https://community.gatling.io/t/inject-users-in-stages/7493/5 "2023-02-08T10:59:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
