Will Thread.sleep affect response time

Hi,
I have added “Thread.sleep(1000)” between two requests and executed the program. We have observed that the response time variation in gatling and our logs for requests.
So, our doubt is whether Thread will affect the response time shown in gatling metrics?

Below is the code snippet:

val scn = scenario("Sample scenario")
      .exec(createProduct)
      .exec(session=>{
        Thread.sleep(975)
        session
      })
      .exec(getUsagePlanForSkuFeaV3_1)

setUp(Activation.scn.inject(stressPeakUsers(210)during (2 minutes)).throttle(reachRps(210) in (1 seconds),holdFor(60 minutes))
).protocols(httpConfig)

Hi @Zuhair,

Gatling engine is based on EventLoop programming. So if your code blocks a (shared) execution thread, the engine cannot manage to have several virtual users in parallel.
You definitely should avoid all blocking computations in Gatling exec.

Cheers!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.