0

Is there any way we can randomize the request per second in Gatling? In the documentation they have provided reachRps and jumpToRps which doesn't provide dynamic request within a range. How can i setup the script to publish request in range of 500 to 1000 per second range?

package sample

import io.gatling.core.Predef._
import io.gatling.http.Predef._

import scala.concurrent.duration._

class PerformanceTest  extends Simulation {

  object rqstObj {
    val getData =
      exec(
        http("Get SourceId")
          .post(SomeURL)
          .body(SomeBody)
          .check(status.is(200))
      )
  }

  val rqst = scenario("Test1")
  .forever(exec(rqstObj.getData))  

    setUp(rqst.inject(
    constantUsersPerSec(18) during (5 seconds)
    ).protocols(httpProtocol)).throttle(
        //Instead of writing the below code, i need something dynamic as we have for rampUser
      reachRps(650) in (1 minute),
      reachRps(950) in (1 minute),
      reachRps(650) in (1 minute)
      ).maxDuration(3 minutes)
}
ABS
  • 61
  • 2
  • 10

1 Answers1

0

You can generate list of throttle steps with random values fe.:

val randomThrottlingA = Array.fill(300){Random.nextInt(50)+50}.map(
  limit => reachRps(limit).in(1 second)
)

Or

val randomThrottlingB = for(_ <- 1 to 300) yield {
  reachRps(Random.nextInt(50)+50).in(1 second)
}

Then you can use it as param for throttle():

setUp(myscenario.inject(injectionProfile).throttle(randomThrottlingA))

Of course list do not need to have random values you can build it based on any algorithm you like.

Mateusz Gruszczynski
  • 1,421
  • 10
  • 18