Endless forever loop


I’m trying to loop over a specific http request during a simulation. The test happens to never end.

Here is my scenario

Here the simulation:

As I can see in the logs, the test never ends. I expect it to last 15 seconds. I have to stop it manually.

What am I missing about the forever loop ?

Any help would be great.
Thank’s !

This e-mail and any attachment are confidential and intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

Let’s respect the environment together. Only print this message if necessary.

Hi Terry,

Your 15.seconds limits the duration of your injection, not the duration of the scenario.

If needed, you may use the maxDuration on your simulation, but I discourage this usage in your case.

The setUp part explains when the different virtual users begin their own script, their scenario.
But it is up to this scenario to be limited in time and to describe the behavior of a single user.

Hope it helps.


Hi Stéphane,

Thank you for your response, it helps, but it raises one more question:

In which case is a forver loop useful, if it never ends ? Which element can override the duration ?

Another questions just popped (because it’s my next step in the scenario): can I somehow execute a last request after the loop statment has been done ? For example I want to empty the basket avec each user synchronized it.

Thank you for your help.


I’m not Stéphane.

About forever loop, I can imagine several use cases:

  • Your test is designed to find the max count for the system under test before crawling. (inject one use per sec forever, and each user make a request sometime)
  • Inside the forever loop, you decide when terminating (exitHere)
  • Only one user with the scenario with the forever loop that “monitors” other users (by getting metric from the system under test)
  • etc.

About your question, I cannot think about a way to manage that after a forever loop.
But you may use a doWhile, and/or a rendezvous to synchronize your different users.
You may also synchronize your users by means outside of gatling, but that is up to you ^^


Waw sorry Sébastien**

Ok thank you, I’ll check all of this.


Hi again,

Sorry but I’m questionning myself about the difference between these 2 ways to inject load:
Let’s assume I have a scenario with 1 request during less than 1 second (API call).
First one:
val scenario: ScenarioBuilder = scenario(“SC01_my_scn”)

Second one:


val scenario: ScenarioBuilder = scenario(“SC01_my_scn”)
.during(200) {


Both of these methods inject 2 request per second during 200 seconds. What is the difference between the 2 solutions?
Does the first one create 2x200 = 400 connection to the API instead of 2 for the second solution ?

Thanks for your help !


Hi Terry,

First one, you have 400 virtual users that each read their scenario containing only one request.
Second one, you have 2 virtual users (starting with 1 second difference)

I cannot ensure that the count of connections will be different (it will depend on server configuration and simulation protocols) but I have the same intuition as yours in Keep-Alive case.

For such a scenario, the difference is not really important, I guess.
But keep in mind, it is better to write a scenario as something a real user will do. A virtual user will have a cookie jar (for authentication), a session (more or less a Map to keep information between requests), etc.