It is not clear to me how I can control a closed workload model in Gatling.
If I use constantConcurrentUsers
, like this:
myScenario.inject(
constantConcurrentUsers(40) during (2 minutes)
)
I thought it meant the number of active users would be constant. But instead, I get reports like this:
Where the number of users is not constant and 3-5 times more than what I wanted.
In the console output though, I can see that something is constant (4 scenarios here, each loaded with 10 constant concurrent users):
But the total load is much more than I would expect.
I had experimented with throttling, and the results had been clear there. In my understanding, the throttle maximizes the number of concurrently active requests (a request is active if it has been sent but not yet responded to). I define a number of requests that should go through, and Gatling sends a new request every time one is done. And because there is not much difference between response times, a report looks like this:
I wanted to do the same thing but so that I can control the length of the simulation, not the total amount of requests sent. constantConcurrentUsers
seemed to be just the thing I needed, but it produces unexpected results. My throttle simulation does approximately 3000 requests in about 1 minute with a throttle of 50. At the same time, if I set 50 concurrent users for 1 minutes, there are more than 7000 requests sent in the report. Response times are way lower in the throttle case. So the throttle simulation sends requests much slower than the concurrent users simulation, but not because the requests take more time.
I know that active users and sent requests are not the same and constantConcurrentUsers
controls the number of users while throttle controls requests. But all my scenarios contain only one request so I don't understand the difference between the results.
So my questions are:
constantConcurrentUsers
?constantConcurrentUsers
?I have read this part of the Gatling documentation, which is really short and lacks a detailed description. I also read this article, which has graphs I have never seen in any Gatling report and doesn't answer my question.
Thank you for any contribution.
I have found that the Cheatsheet describes each injection step most accurately. How you inject a constant number of users should be using constantConcurrentUsers
which is described in the Cheatsheet as: "Maintain a constant number of concurrent users"
As for your other questions:
- What exactly is constant when I use constantConcurrentUsers?
I believe Gatling does keep the number of concurrent users constant. The reason there are spikes in the number of requests is because one user can make multiple requests in a given timespan. As soon as the current request finishes for the user, a new request is fired by the same user. In your example, you had 40 users
and your number of requests
looks around 80, this indicates each user was achieving 2 requests a second (mean response time around 500ms?)
- How is the number of requests calculated when I use constantConcurrentUsers?
As per above, your concurrent users will just keep looping the request for the duration you set and it will not fire another until the current request provides a response. If your API is quick, your number of requests per second will be higher than your number of users.
- What is the relation between "active users" in the report and "active" in the console output?
This is actually where I am a bit unsure :/ I set have 10 constantConcurrentUsers
in my test, and console shows similar to yours, but my report shows between 10-75 active users over time
However, this Reports page in Gatling docs sheds some light:
“Active users” is neither “concurrent users” or “users arrival rate”. It’s a kind of mixed metric that serves for both open and closed workload models and that represents “users who were active on the system under load at a given second”.
It’s computed as:
(number of alive users at previous second) + (number of users that were started during this second) - (number of users that were terminated during previous second)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With