How can I implement dynamic pause length ?

I have a requirement to customize pause time to evenly distribute requests. For example, to simulate one user sends 10 requests at 1 req/min rate, I cannot use fixed pause time between requests since they have different response time. So for request1 and request2, I need pause behavior like this: pause(1min - response time of request1 ). Suppose I have scenario as below, how can I implement the dynamic pause length?
val scn = scenario(“Test Scenario”)
.exec(http(“request1”)
.get(“http://host/…”)
.queryParam(…)

)
.pause({dynamic pause length})
.exec(http(“request2”)
.get(“http://host/…”)
.queryParam(…)

)

Possibly See issues 625 and 378.
This is called pacing.

Thanks
Alex

We call it throttling now :slight_smile:
The feature is already there in master and will be in 2M4.
However, it works globally, not per user.

Then, with a 1 req/min per user rate, wouldn’t response time be neglectible compared to pause time?

A possible solution would be to:

  • store a timestamp with an exec(function) before executing the request

  • dynamically compute the pause duration
    Would be something like this:

exec(.set(“beforeRequestTimestamp”, System.nanotime))
.exec(request)
.pause(
(“beforeRequestTimestamp”).validate[Long].map(before => (1000000000 - System.nanotime + before) nanoseconds))

Get it?

Cheers,

Stéphane

Hi Stéphane,

Thanks, A response time could be very variable and long, we don’t know in advance. It also depends on the test requirements whether the effect of that is negligible on the target throughput.

I read #693 also but not totally sure what was committed in the end?

Mes salutations les plus distinguées!
Alex

We call it throttling now :slight_smile:
The feature is already there in master and will be in 2M4.
However, it works globally, not per user.

Then, with a 1 req/min per user rate, wouldn’t response time be neglectible compared to pause time?

A possible solution would be to:

  • store a timestamp with an exec(function) before executing the request

  • dynamically compute the pause duration
    Would be something like this:

exec(.set(“beforeRequestTimestamp”, System.nanotime))
.exec(request)
.pause(
(“beforeRequestTimestamp”).validate[Long].map(before => (1000000000 - System.nanotime + before) nanoseconds))

Get it?

Cheers,

Stéphane

Hi Alex,

Throttling let you shape the desired number of requests per second, assuming you run enough users to generate enough load.
Basically, it queues every second the excessive load, so accuracy is 1 second (it cannot throttle to something less than 1 req/sec).
I also works globally, or at population level (protocol) but not per user.

You’d have to hack the way I indicated.

Cordialement,

Stéphane