Are Gatling exec {session => ...} blocks synchronized between users?

Hi there,

I have a Gatling scenario in which, for each user, I need to execute some preliminary steps on the system using Selenium/headless Chrome via execute {session => …}. This takes about 30 seconds for a single user. I noticed that only one Chrome instance is active at a time, suggesting that the exec block is synchronized somehow. Even with two users, the second user waits until the first user finishes that block.

Is there some kind of synchronization at play? Any way to work around it?

No, there isn’t.

I must be completely missing something then. I have this minimal simulation:

class TestSimulation extends Simulation {
private val scn = scenario(“Test”)
.exec {session =>
println(s"User ${session.userId} waiting")
Thread.sleep(10000)
println(s"User ${session.userId} finished")
session
}
setUp(scn.inject(atOnceUsers(10)))
}

In the log, I can clearly see:

User 1 waiting
User 1 finished
User 2 waiting
User 2 finished
(…)

And the entire test takes 100 seconds. What might be the reason of this?

Your original question was about synchronization, which is about memory barriers.

What you’re doing now is blocking execution threads for a very long time, which is something you mustn’t do.

Yes, because I suspected it was the reason for other users being blocked, and not blocking the execution thread. I forgot how Gatling works :slight_smile:
Thanks for the explanation.