CyberNinja
CyberNinja

Reputation: 93

Use of pace in gatling to control rate

I have following scenario which has two requests (RequestOne and RequestTwo). It is setup to run for 3 users and 1 repetition. The simulation should have taken at least 20 seconds to finish as I am using 20 seconds as pacing. However, every time I run it, it finishes in less than 20 seconds. I tried with different values for pacing as well.

val Workload = scenario("Load Test")
.repeat(1, "repetition") {
    pace(20 seconds)
    .exitBlockOnFail {
        .feed(requestIdFeeder)
        .group("Load Test") {
            .exec(session => {
                session.set("url", spURL)
            })
            .group("RequestOne") {exec(requestOne)}
            .feed(requestIdFeeder)
            .group("RequestTwo") {exec(requestTwo)}
        }
    }
}

setUp(Workload.inject(atOnceUsers(3))).protocols(httpProtocol)

output

Simulation com.performance.LoadTest completed in 11 seconds

Upvotes: 1

Views: 6832

Answers (1)

CyberNinja
CyberNinja

Reputation: 93

Found the problem. I used only 1 repetition so the scenario didn't need to wait for the 20sec pacing to complete and it exited early. Setting repetition to > 1 helped achieve the desired rate.

val Workload = scenario("Load Test")
   .repeat(10, "repetition") {
     pace(20 seconds)
       .exitBlockOnFail {

So, if you want to achieve fixed number of transactions in your simulation, use repetition, otherwise use "forever (" as mentioned in gatling docoumentation to achieve consistent rate.

val Workload = scenario("Load Test")
   .forever (
      pace(20 seconds)
        .exitBlockOnFail {

Upvotes: 2

Related Questions