Inject command for gradual ramp up and hold and then ramp down

We are trying to run a test where users ramps up and then the load is held for some duration and then user gradually ramps down.
Can someone suggest what should be the inject commands that should be used to achieve the below user simulation.

In this image x axis is time, and y axis is user count.

Hey there,

In cases like this we prefer if you try it on your own first and then post code that we can correct rather than writing it for you. This is in the basic spirit of this community. I suggest reading about the core concepts of injection here: https://gatling.io/docs/gatling/reference/current/core/injection/

Would also recommend taking the Gatling Academy Modules if you’re new to Gatling: Gatling Academy - Become a load testing leader

All the best,
Pete

1 Like

Hi @GatlingPete ,
Below here are my code, I am also trying to implement the same injection model of the topic

import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class BasicSimulation extends Simulation{
val scn  = scenario("listUser") 
        .exec(http("listUser") 
            .get("/api/users?page=2")
            .check(
                    status.is(200), 
                    jmesPath("data[?id==`7`]").ofType[String].exists 
                  )
        ) 
        .pause(3)

setUp(
       scn.inject(constantUsersPerSec(10).during(5))
   ).maxDuration(10).protocols(httpProtocol)
    .assertions(
        global.responseTime.max.lte(2000),
        global.failedRequests.percent.lte(5)
    )   
}

By far, I have achieved the topic model, however, I cannot differentiate about users rate and active users yet, could you explain more so that I can calculate exactly the active users that I want based on time and rate ?

I would really suggest looking at the Gatling Academy module 1, to learn about open and closed injection profiles and how to set them up in Gatling. Here it looks like you’re trying to run a pretty simple load test from your graph but from your code it looks like you’re only trying to run it for 10 seconds? To get the graph you’re looking for you can go with a simpler injection profile:

setUp(
      scn.inject(constantUsersPerSec(10).during(10))
    ).protocols(httpProtocol)

If you’re looking to Ramp users before or after you can use the rampusers(X).during(X) building block in the setup.

If you’re brand new and looking to generate some simple types of tests I might also recommend checking out Gatling Enterprise Cloud and our new no-code generator which can help you get started and show you the code for some simple injection profiles and types of test.

Finally, are you trained in Scala? If not I would really suggest starting in Java as it’s a bit more accessible.

Let me know if that helps.

All the best,
Pete

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