How to set max constant number of active users?

Hello

I have such script

`

val httpConf = http
.baseURL(“url”)
.header(“Content-Type”, “application/json”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)
.disableClientSharing
.maxConnectionsPerHost(1)

val scn = scenario(“Scenario Name”)
.exec(session => session.set(“key”, Random.nextLong().abs))
.exec(session => session.set(“UUID”, UUID.randomUUID().toString))
.exec(http(“users batch create”)
.post("/users/batch")
.body(StringBody(createRequest(1000, “${UUID}”)))
.check(status.is(202)))

setUp(scn.inject(constantUsersPerSec(7) during(60 seconds))).protocols(httpConf)

`

In this case I see growing number of active users that is not my planned load.

How can I emulate situation when sessions pool will wait for response before opening new connection?
Is it possible to limit number of active users somehow?

Br,
Denis

That’s because the test is setup inject 7 user every second. so your active user graph is going to look like a peaky mountain. On top of that you have no pause or delay between request which users would normally do… unless you tell me this is a batch job or something.

You should use rampUsers over n seconds instead. Like this one

setUp(scn.inject(rampUsers(420) over(60 seconds))).protocols(httpConf)

This will ensure you will have 7 constant user for the duration of the test and add .pause(n) between your requests after check. n = number in seconds. you can also randomize by using .pause(1,5) pause randomly between 1 to 5 sec.

Good luck!

Hi,

I don’t need static pauses or rampUp. I want to have a pool of 7 active sessions. Next requests will not be sent until response will come from previous one. Response time in my case is dynamic - for one request it may take 1 sec for other 30 secs.
But even with 30 sec response time I don’t want my active users pool to grow up.

Is it possible to implement this with Gatling?

hmm interesting. What’s the purpose of testing it that way? It seems overly complicated to me and to configure in gatling but that’s just my opinion. Gatling is a stress testing tool, don’t see any stress here with 7 active session where the requests are sequential & dependent in nature. Perhaps you can write a separate script that does that and create a simulation file then generate a report using gatling. Feels like the attempt here is to fit a square peg in a round hole but again that’s just my opinion :slight_smile:

Hopefully someone more knowledgeable could help you.

Every opinion is welcome)

While I was writing answer have understood that you are right ))

Sometimes when you test new project devs trying start you thinking in a wrong way) Cause their servers couldnt be slow)

Many thanks! You helped a lot.