Fixed number of iterations in ramping-arrival-rate executor

Hello

I have parametrized k6 script with data, requests are closely connected with each other, sometimes I need to retrieve some data from response in one step and in next I am using it, and I have prepared it, but problem is with choosing right executor.

I need to run 20 datasets(iterations) in 10 minutes.

I don’t understand why executor ramping-vus and ramping arrival rate run more scenarios that it is defined.

e.g

executor:'ramping-arrival-rate',
startRate: 1,
timeUnit: '1m',
preAllocatedVUs:1,
maxVUs:20,
stages:[
   {target:20, duration: '10m'}
]

after target is exceeded, new scenarios are still triggered, same with ramping-vus. I have defined target to 20 but all iterations performed was 104. And requests of course are failing after 20 iteration, because data are incorrect, because they doesn’t exists.

I want to ask what scenario allows me to run opened model scenario in which next iteration doesn’t wait until the previous one finishes, and each iteration with dataset will start with e.g 1s of delay.

Should it be simple shared-iterations executor w

      executor: "shared-iterations",
      vus: 1,
      iterations: 20,
      maxDuration: "10m"

with counter and delay
delay = delay+1
sleep(delay)

or maybe you know how to stop ramping-arrival-rate after exceeding target, because I was trying to add condition

if(dataset.length === exec.scenario.iterationInTest)
return;

but it didn’t stop triggering scenarios.

Hi @Developer

Welcome to the community forum :wave:

With a ramping arrival rate executor like yours:

startRate: 1,
timeUnit: '1m',
maxVUs:20,
stages:[
   {target:20, duration: '10m'}
]

What k6 will do is try to run 20 requests per minute (the timeUnit) during 10 minutes. So depending on the time the service takes to respond, you can indeed expect around 100 or 120 requests to happen. It makes sense that you get around 104.

The script below will not stop triggering scenarios, just start the next VU code execution/ VU stage.

if(dataset.length === exec.scenario.iterationInTest)
return;

If you want to run a fixed number of iterations an open model might not be the way to go. I would go for a per-vu iterations, shared iterations, etc. Depending on your concrete needs. Can you further elaborate why you need an open model if you want only one iteration?

If you want each VU to run unique data, you can do that with data parameterization.

Can you share a bit more detail of your context? Sometimes sharing the (sanitized) script allows us to better understand your requirements.

I hope this helps.

Cheers!