Emulate load with few requests simultaneously that repeated after some period of time

Hi all,
I am looking for the opportunity to emulate the scenario where system sends 10 requests at the same moment of time and than repeats it again after 1 sec during some period of time.
Something like: 10 requests at once - 1 sec pause - 10 requests at once - 1 sec pause…

If I use constantUsersPerSec(10).during(duration) the system generate load in format:
1st request - 100ms pause - 2nd request - 100ms pause…
As I understand, constantUsersPerSec(10).during(duration).randomized also doesn’t emulate needed behavior.

To implement needed load I found construction:
inject((1 to duration).flatMap(i => Seq(atOnceUsers(10), nothingFor(1))))
which gives me needed results, but want to know if exists any other options that I miss.

Thanks in advance

Your solution is the correct and only way.

1 Like

My proposition for this case in Java → Case0014Loop5times1RPSand3sPauseSimulation
@slandelle @sbrevet can you check if it’s optimal.

The most important piece of code:

{
        setUp(scn.injectOpen(
                Stream.generate(
                        () -> new OpenInjectionStep[]{
                               atOnceUsers(1),
                               nothingFor(Duration.ofSeconds(3))
                        }
        ).limit(5).flatMap(Stream::of).toArray(OpenInjectionStep[]::new)
        )
                .protocols(httpProtocol));
    }
2 Likes

@GeMi That’s correct, except it’s best to not expose OpenInjectionStep which is not part of the recommended imports.

1 Like

@slandelle thank you very much for improving the code.
Push to main repo in progress… :slight_smile: