Pause Functionality is not working

Hi, I am currently facing some issue that pause functionality is not working as expected. I need 975 milliseconds between two requests and I have added pause after execution of first request, but it is not pausing there and hitting second request without delay.

Below is the code snippet:

.exec(getActivationsOfMemberInV3)
.pause(975 milliseconds)
.exec(flushHttpCache)
.doIf(session => session("GetActivationOfMemberV3Status").as[Int] == 200) {
    exec(getActivationsOfMemberLiveData)
    .pause(100 milliseconds)
}

Are you using throttle?

What throttle do is that it:

  • disables all the pauses
  • caps your throughput. It can’t generate a throughput that’s higher than the one normally generated by your simulation once pauses are disabled.

Hi Slandelle, yes I have used stressPeakUsers and throttle for my scenario.
So, how we can achieve pause when applying throttle?

That’s not possible, these features are antinomic.

Then, is there any method to control the threshold other than throttle so that I can apply pause?

You must remodel Simulation to use Injection Profiles → https://gatling.io/docs/gatling/reference/current/core/injection/

Hi Gerard, is there any sample code for my reference to set the threshold and apply pause delay? Providing some sample scenario, apply threshold of 50 TPS for 10 minutes and 100 TPS for next 5 minutes with 975 milliseconds between two requests of same scenario?

In Gatling there isn’t TPS there are Virtual Users.
Sample Scenario that make injection what you mentioned using incrementUsersPerSec below - of corse for smaller scale and level lasting time are the same but this should show you idea how to:

package pl.gemiusz;

import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;

import java.time.Duration;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;
import static io.gatling.javaapi.http.HttpDsl.status;

public class Case0004StatusCodeSimulation extends Simulation {

    HttpProtocolBuilder httpProtocol =
            http
                    .baseUrl("https://postman-echo.com");

    ScenarioBuilder scn =
            scenario("GeMi_StatusCodeSimulation")
                    .exec(
                            http("GeMi_StatusCodeSimulation_get_414")
                                    .get("/status/414")
                                    .check(status().is(414))
                    )
                    .pause(Duration.ofMillis(950))
                    .exec(
                            http("GeMi_StatusCodeSimulation_get_424")
                                    .get("/status/424")
                                    .check(status().is(424))
                    );

    {
        setUp(scn
                .injectOpen(
                    incrementUsersPerSec(5.0)
                    .times(2)
                    .eachLevelLasting(Duration.ofSeconds(10))
                    .separatedByRampsLasting(Duration.ofSeconds(5))
                    .startingFrom(0) // Double
                )
                .protocols(httpProtocol));
    }
}

Hi @GeMi ,
But we can’t run this for any fixed duration. It will end once all virtual users execute the scenario.
Our need is to run the scenario for one hour with some virtual users along with intermediate spikes(also apply delay between two requests). Is there any code snippet available with you to accomplish our requirement?

Check Gatling documentation and Maximum Duration

I’m sorry, but you’ll have to figure it out yourself - it’s easy to do but you must known how Injections are working.

Cheers!

ok @GeMi, I will explore it.

Thanks for the info.

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