Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gatling Throttle holdfor not working

New to Gatling world but an experienced Loadrunner user. I created a sample simulation to run two scenarios, each with 10 users and want to run it for 10 minutes. Below is what I have in my setUp function. But each time I run the simulation, it only runs for 136 seconds. The holdFor doesn't seem to take into effect.

setUp(
    scn.inject(rampUsers(10) over (10 seconds)),
    scen.inject(rampUsers(10) over (10 seconds))
)
.protocols(httpProtocol)
.throttle(
    reachRps(2) in (10 seconds),
    holdFor(10 minutes)
)

I am using Gatling 2.2.2 bundle.

Output: Simulation computerdatabase.BasicSimulation completed in 136 seconds

like image 861
CyberNinja Avatar asked Aug 02 '16 02:08

CyberNinja


1 Answers

The throttle works as a bottleneck, effectively working as an upper boundary for how many requests will be sent. If your scenarios + injection profiles aren't able to generate as many requests as you would like in the first place, the ones that are generated simply pass through the throttle unhindered. The throttle cannot increase the load to match the desired RPS, it can only decreases it.

You will need to inject enough users into your scenarios for them to be able to generate the 2 RPS you want in the first place, and keep adding more of them over the course of the simulation, in order for the throttle to do what you are looking for.

Try changing your injection profiles to for example something like this (and adjust the constantUsersPerSec value as needed), I believe this might give you a load-profile a step closer to what you are looking for:

scn.inject(constantUsersPerSec(1) during(10 minutes))),
scen.inject(constantUsersPerSec(1) during (10 minutes)))

The example above was just a very quick and dirty way to illustrate the point of having to inject users over time, but as chance would have it, injecting 600 users in total over 10 minutes into a scenario is 10 users every ten seconds and should be exactly what you want, unless I'm falling ass first into a basic arithmetic error and/or misunderstanding.

It will also naturally ramp up and down to some extent, although you can more explicitly control the ramp up by chaining injection steps if you need, for example like this:

scn.inject(
    rampUsers(10) over (1 minute),
    constantUsersPerSecond(1) during (10 minutes)
)

For another approach to more explicitly control the ramp over time, you could also play around with a configuration like this:

scn.inject(
    splitUsers(600) into(rampUsers(10) over(10 seconds)) separatedBy(10 seconds)
)
like image 199
Kim André Kjelsberg Avatar answered Oct 11 '22 22:10

Kim André Kjelsberg