Gatling: Keep fixed number of users/requests at any instant
Asked Answered
B

2

5

how can we keep fixed number of active concurrent users/requests at time for a scenario.

I have an unique testing problem where I am required to do the performance testing of services with fixed number of request at a given moment for a given time periods like 10 minutes or 30 minutes or 1 hour.

I am not looking for per second thing, what I am looking for is that we start with N number of requests and as any of request out of N requests completes we add one more so that at any given moment we have N concurrent requests only.

Things which I tried are rampUsers(100) over 10 seconds but what I see is sometimes there are more than 50 users at a given instance.

constantUsersPerSec(20) during (1 minute) also took the number of requests t0 50+ for sometime.

atOnceUsers(20) seems related but I don't see any way to keep it running for given number of seconds and adding more requests as previous ones completes.

Thankyou community in advance, expecting some direction from your side.

Backlash answered 27/4, 2019 at 21:43 Comment(0)
C
4

Use the Closed Work Load Model injection supported by Gatling 3.0. In your case, to simulate and maintain 20 active users/requests for a minute, you can use an injection like,

Script.<Controller>.<Scenario>.inject(constantConcurrentUsers(20) during (60 seconds))
Ced answered 8/5, 2019 at 10:59 Comment(5)
I was talking about number of request Venkat, not users.Backlash
Oh yeah, I was referring to requests, when I said users. Were you not able to achieve 20 concurrent requests with this?Ced
Achieving is easy, what I am looking for was something for throttling. This will start having much more open requests in a while after test startsBacklash
But when I tried, I had only the specified number of requests open at any instant during the whole test, when I use constantConcurrentUsers. In this case, only 20 requests will be open through out the whole execution time(60 seconds).Ced
this answer is exactly what you want - there will always be 20 active users at a time - as each completes a new one will be injected to take its place.Collins
I
3

There is a throttling mechanism (https://docs.gatling.io/reference/script/core/simulation/#shaping-throughput) which allow you to set max number of requests, but you must remember that users are injected to simulation independently of that and you must inject enough users to produce that max number of request, without that you will end up with lower req/s. Also users that will be injected but won't be able to send request because of throttling will wait in queue for they turn. It may result in huge load just after throttle ends or may extend your simulation, so it is always better to have throttle time longer than injection time and add maxDuration() option to simulation setup.

You should also have in mind that throttled simulation is far from natural way how users behave. They never wait for other user to finish before opening page or making any action, so in real life you will always end up with variable number of requests per second.

Iconium answered 28/4, 2019 at 15:4 Comment(2)
I know that but in our case we just want to test the endurance of mictoservice for different hardware specs. So that accordingly we can write our cloud horizontal scaling rules.Backlash
And please try to add a complete sample solution as I am not able achieve with throttle what I am expectingBacklash

© 2022 - 2024 — McMap. All rights reserved.