How to correct user injection?

Hello everyone, I’m not that proficient with user injections so I would like to ask for some help. We have a scenario by which users should be injected:
30 minutes - stable load, then 30 minutes of spike with a big number of users and that repeats again.

setUp(TestScenario.scenario
                .injectOpen(
                        constantUsersPerSec(ConfigHelper.USERS_PER_SECOND).during(Duration.ofMinutes(ConfigHelper.CONSTANT_USER_RATE_DURATION)),
                        stressPeakUsers(ConfigHelper.SPIKE_USERS_NUMBER).during(Duration.ofMinutes(ConfigHelper.SPIKE_DURATION)),
                        constantUsersPerSec(ConfigHelper.USERS_PER_SECOND).during(Duration.ofMinutes(ConfigHelper.CONSTANT_USER_RATE_DURATION)),
                        stressPeakUsers(ConfigHelper.SPIKE_USERS_NUMBER).during(Duration.ofMinutes(ConfigHelper.SPIKE_DURATION)),
                        constantUsersPerSec(ConfigHelper.USERS_PER_SECOND).during(Duration.ofMinutes(ConfigHelper.CONSTANT_USER_RATE_DURATION))
                )
        ).maxDuration(Duration.ofMinutes(ConfigHelper.DURATION))
                .protocols(ConfigHelper.httpProtocol)
                .assertions(global().successfulRequests().percent().gt(ConfigHelper.SUCCESS_RATE));

We have executed this code with parameters such as:
Users per second: 15
Constant user rate duration: 30
Spike users number: 400
Spike duration: 30
Test Duration: 150

But numbers of users were not like a would expect:

I wanted to create a quite opposite picture from the one that I provided. Like 200 or so users during constant rate and big spike with 400 users during the spike.

So, I would like to have some guidance, thank you in advance :smile:

You misunderstand stressPeakUsers. Quoting the documentation:

Injects a given number of users following a smooth approximation of the heaviside step function stretched to a given duration.

With your values, each peak will inject a total of 400 users. Over 30 minutes, that’s merely ~1 every 5 seconds.

Oh, so I was wondering why is it happening…would you suggest something different so that I can use it to simulate the scenario that we want? Or do we just need to increase the number of users?

Just increase the number of users.
A 30 min spike is really not a spike:slight_smile:

1 Like