[SOLVED] Why first Gatling request is slower?


I have a Gatling scenario where I’m calling the Gatling demo app endpoint. I noticed that the first request is taking a higher time to respond to.
For example:

public class OneEndpointSimulation extends Simulation {

HttpProtocolBuilder httpProtocol = http
        .acceptEncodingHeader("gzip, deflate")
        .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0");

ScenarioBuilder scn = scenario("BasicSimulation")


Screen of Gatling report

Here is simulation.log file result:

RUN activitydatabase.OneEndpointSimulation  oneendpointsimulation   1647472671275       3.7.5
USER    BasicSimulation START   1647472672290
REQUEST     request_1   1647472672322   1647472672578   OK   
REQUEST     request_1   1647472672614   1647472672740   OK   
REQUEST     request_1   1647472672742   1647472672867   OK   
REQUEST     request_1   1647472672868   1647472672992   OK   
REQUEST     request_1   1647472672994   1647472673121   OK   
REQUEST     request_1   1647472673123   1647472673244   OK   
REQUEST     request_1   1647472673246   1647472673368   OK   
REQUEST     request_1   1647472673371   1647472673492   OK   
REQUEST     request_1   1647472673494   1647472673616   OK   
REQUEST     request_1   1647472673618   1647472673741   OK   
USER    BasicSimulation END 1647472673748

Is there any way to speed up the first request?


You’re getting it wrong, this is expected.

Because of the way your test is designed, the first request takes more time because it has more work to do:

  • perform the DNS resolution
  • open the HTTP connection

The next requests for this single virtual user will skip this extra work because:

  • the DNS resolution will be in cache
  • they will reuse the same keep-alive HTTP connection

Answered By – Stéphane LANDELLE

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *