Search code examples
scalaconcurrencyload-testinggatling

Execute parallel requests in Gatling


I am trying to model a Use-Case in Gatling, in which I need the repeat()-method to execute each iteration in parallel, instead of sequentially like this:

scenario("Scenario")
  .exec(groupExecutedInSequence)
  .repeat(5) {
    exec(groupExecutedInParallel)
  }
  .exec(anotherGroupExecutedInSequence)

However for the time being, I could not find a way to achieve this. I tried to use multiple scenarios, so that I could inject different numbers of users into each step of the Use-Case:

setUp(
  stepOne.inject(atOnceUsers(2))
    .andThen(stepTwo.inject(atOnceUsers(10))
      .andThen(stepThree.inject(atOnceUsers(2)))))
)

In this case, the second scenario would be executed five times, for each execution of step one and three. However with this solution, step two only executes when all the users of step one have finished, which is not the intended Use-Case. Instead, when one user in step one has finished, step two should execute five times immediately. Therefore a solution using multiple scenarios doesn't seem to do the trick.

Is there a solution to make the code block of the repeat()-method execute in parallel instead of sequentially, or any other way to make this Use-Case work in Gatling?

Thank you in advance :)


Solution

  • As of Gatling 3.7 (and also for upcoming 3.8), the only way Gatling has to send requests in parallel for a given virtual user is resources.