[Gatling2] my sessions for virtual users executed sequentially, not in parallel


I am using gatling 2.3.1, but same behavior happened on earlier version of gatling.

I am trying to put some code in session section and I have noticed that my scenario is not executed in parallel for virtual users.
Here is simple scenario:

class TestSimulation extends Simulation{

  val scn: ScenarioBuilder = scenario("Test")
      println("====> start " + session.userId + "; " + Thread.currentThread().getId)
      println("====> message sent " + session.userId + "; " + Thread.currentThread().getId)

  setUp{ scn.inject(atOnceUsers(10))

I would expect that sessions for all 10 users would be started at once, and then will finish one by one, but in my output I see something like this:

====> start 1; 12

====> message sent 1; 12

====> start 2; 12

====> message sent 2; 12

====> start 3; 12

====> message sent 3; 12 ... and so on

My system has Processor Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz, 3401 Mhz, 4 Core(s), 8 Logical Processor(s)

Is there any settings to force gatling to use all cores and execute this code in different threads?

Gatling 2 has reached end of life last year and is no longer maintained. Please upgrade to latest Gatling 3 (Gatling 3.2.0 will be released tomorrow).

Result with Gatling 3:

====> start 4; 16
====> start 6; 19
====> start 3; 17
====> start 10; 23
====> start 7; 20
====> start 1; 15
====> start 2; 13
====> start 8; 21
====> start 5; 18
====> start 9; 22
====> message sent 6; 19
====> message sent 9; 22
====> message sent 10; 23
====> message sent 5; 18
====> message sent 8; 21
====> message sent 2; 13
====> message sent 1; 15
====> message sent 3; 17
====> message sent 7; 20
====> message sent 4; 16

Then, please note it’s super wrong to perform blocking operations such as Thread.sleep in Gatling’s threads.

Hi Stephane,

Thank you for response.
I have updated my scripts to Gatling 3, but nothing changed for me.
I tried different build tools - sbt and gradle plugin (com.github.lkishalmi.gatling). Executed this script with windows and linux and nothing works for me.
None of my scripts are working in parallel, this dummy scenario just shows my issue. If someone faced same setup issue please help.

Internally there’s a thread pool. If you have only one thread there and it got blocked, no other actions of the virtual users can be performed.

To make the virtual user sleep you want to use pause.

Hi George,

Thank you for response.
I am using Thread.sleep to imitate my real script, which can execute one request up to 11 seconds.
It seams that my gatling application can create only one thread for some reason, but your response made me thinking about looking deeper into managing akka’s thread pools via dispatchers.

Hi Kateryna,

While I always like digging deep, I don’t think looking at Akka’s/Gatling’s internals is going to help before you clear up the confusion over Gatling’s surface API .

In Gatling, requests are described in the DSL; and their execution, which are done behind the scenes, do not block threads.
Quoting the README on github, it uses “Async Http Client and Netty for non blocking HTTP”.
When the virtual user is waiting for the server’s response, the thread that sends the request does not sit idle, but moves on and does other stuff.
That is why Thread.sleep, which blocks threads, is a poor imitation of Gatling’s requests.

That also means if you are using a protocol that is not supported, it will take some effort to integrate it into a Gatling test.
We may be able to help if we know more than “I want 10 threads to sleep in parallel.”.