Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inject a constant number of users in Gatling?

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:

40 constant concurrent users?

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):

Console output of 40 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:

Constant number of sent requests with throttle

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:

  • What exactly is constant when I use constantConcurrentUsers?
  • How is the number of requests calculated when I use constantConcurrentUsers?
  • What is the relation between "active users" in the report and "active" in the console output?

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.

like image 322
zslim Avatar asked Jan 02 '20 13:01

zslim


1 Answers

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 10 constantConcurrentUsers

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)

like image 157
Jack Middleton Avatar answered Oct 23 '22 16:10

Jack Middleton