My question is somehow related to this and this , but somehow doesn't really answer my question.
My test case is pretty simple, I need to generate constant active concurrent users (e.g. 10 concurrent users) constantly over a period of time (e.g. 60 sec).
My codes look like this
val TestProtocolBuilder: HttpProtocolBuilder = http.baseUrl("https://computer-database.gatling.io")
object Test {
val test =
exec(http("Test_Only")
.get("/computers")
.check(status.in(200, 404))
)
}
val TestOnly = scenario("Test Only").exec(Test.test)
setUp(
TestOnly.inject(
constantConcurrentUsers(10) during(60 seconds)
).protocols(TestProtocolBuilder)
)
This documentation says
constantConcurrentUsers(nbUsers) during(duration)
: Inject so that number of concurrent users in the system is constant
I am expecting to get 10 concurrent active users constantly hitting the API for 60 seconds. No more than 10 users and no less than 10 users at any time.
What I see in the HTML report is that the active users at any given time is much higher than 10 (almost double).
Learning from the documentation , it says
This chart displays the active users during the simulation : total and per scenario. “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)
Questions:
- Why Gatling keep terminating users and starting new users during the test period? What's the point?
- How can I get a constant 10 concurrent active users (no more, no less) keep hitting my API for the duration of the test, if
constantConcurrentUsers(10) during(60 seconds)
give me a much higher active users and keep fluctuating during the test period ? I need to stick to my test case and not over-loading the API. - In the image above, at that given time
the number of request = 7
andthe active users = 20
. Does it mean that at that given time, there are 7 active users sending out requests and there are 20 - 7 = 13 active users sitting idle waiting for the responses to come back from the API ?
Thanks.