Gatling Throttle holdfor not working
Asked Answered
D

1

5

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

Decurrent answered 2/8, 2016 at 2:19 Comment(1)
to clarify, 136 seconds is the approximate time it takes to execute one iteration of all the requests triggered by those 10+10 users.Decurrent
U
14

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)
)
Unfrequented answered 3/8, 2016 at 10:45 Comment(3)
Thanks. I misunderstood the usage of throttling. I think your code will inject around 600 users in total (1 user per second for 10mins for 2 scenarios). This is not what I want. My objective is to load 20 users into the test over 10sec, then keep those 20 running for 10 mins and then ramp downDecurrent
Wrote a reply as a comment initially, but it turned too long. Updated the answer above instead.Array
This answer helped me in understanding the concept so marking this question as answered.Decurrent

© 2022 - 2024 — McMap. All rights reserved.