Gatling scenario with 10 requests per hour (less that 1 rps)
Asked Answered
A

1

7

I need to write Gatling scenario that will mimic real users interaction. It's supposed to issue some requests occasionally, e.g. 10 per hour per user (total 20 users).

From what I see in the docs, constantUsersPerSec accepts double but it's rounded while reachRps in throttling deals only with seconds. So, not way to have less than 1 rps.

It is possible to write such scenario using Gatling?

Anadem answered 3/11, 2016 at 14:15 Comment(0)
M
4

So your scenario seems like "for 2 hours, send a request every 6 minutes" or "at a constant rate of 10 users per hour during 2 hours ...".

Option 1

The constantUsersPerSec is internally rounded to int after multiplying it to the number of seconds of the duration. So the duration should be chosen with respect to the rate, so that the result is greater than 1.

In your case,

def perHour(rate : Double): Double = rate / 3600

constantUsersPerSec(perHour(10)) during(2 hours)

This would result in

10/3600 users * (2 * 60 * 60) seconds = 20 users

Option 2

via injection steps

setUp(
  scn.inject(
    atOnceUsers(1),
    nothingFor(6 minutes),
    atOnceUsers(1),
    nothingFor(6 minutes),
    //... and so forth...
  )
)

or produce the injection steps in a second method

def injections(): List[InjectionStep] = List(...)

setUp(scn.inject(injections : _*))
Mccarter answered 7/11, 2016 at 8:3 Comment(2)
I use Gatling 2.2.0 and it does accept values below 1, I define my load based on a per-minute spec, i.e. 5 users per minute, which translates to 0.4167 users per sec, and that is working. What Gatling does not accept is a rampUsersPerSec with 0Hosey
One additional thing, there seems a bug in Gatling at least up to 2.2.3 (github.com/gatling/gatling/issues/3205), that distributes load between 0-1 user/sec rounded to seconds, so only fractions that have whole-number seconds between users work properly, others are either flattened or compressed. I.e. 0.5, 0.4, 0.3, 0.25, 0.2 etc work well, 0.6 doesn'tHosey

© 2022 - 2024 — McMap. All rights reserved.