Search code examples
load-testinggatlingscala-gatling

How to setup ramp down time in gatling?


I have a jmeter scripts to ramp up 20 users over 20 minutes(1 user every minute) and hold for 30 minutes and ramp down 1 user per minute.

How do i achieve this in Gatling?

I tried below setting in gatling,

SAAPIBase.scn_SA_Auth.inject(rampUsers(20) during (20 minutes)).protocols(httpConf)
).maxDuration(50 minutes)

This ramps up 20 users for 20 minutes and holds for 30 minutes with 20 users. But after that suddenly it drops to zero.

How do I slowly ramp down 1 by 1 user every minute?


Solution

  • Note how long your simulation runs is heavily impacted by the scenarios you're running - all the gatling DSL injection steps control when users get started, and that is all. So if you have scenarios that are very long running or unpredictable, then it's difficult to guarantee something exactly like what you've specified.

    In your example

    .inject(rampUsers(20) during (20 minutes)).protocols(httpConf)
    ).maxDuration(50 minutes)
    

    you inject 20 users evenly over 20 minutes (so one every minute). If that is indeed being held for 30 minutes after the ramp then your scenarios are probably looping and the users get stopped by the maxDuration statement.

    for a ramp-down, you could change your injection to be

    .inject(
      rampConcurrentUsers(1) to(20) during(20 minutes),
      constantConcurrentUsers(20) during (30 minutes),
      rampConcurrentUsers(20) to(1) during(20 minutes)
    )
    

    this will give you the same ramping up over 20 minutes, then will keep injecting users as others finish to maintain 20 concurrent users over the next 30 minutes, then gradually slow the rate of injection over the final 20 minutes. However, if your scenario is using loops like .forever to keep running, this ramp-down won't work as the users injected in the 1st command will never stop.