Throughput when using ramping-arrival-rate

Hi everyone.

Let me get straight to the point. :slight_smile:

The default function of my k6 test will run through 50 different requests. So each iteration = 50 requests.

I want to create a 15 minute load test that does the following:
5 minutes β†’ 100 RPS
5 minutes β†’ 300 RPS
5 minutes β†’ 200 RPS

What would be the best way to achieve that?

I tried using the following options, but the script usually results in a significantly smaller throughput than expected.

export let options = {
  scenarios: {
    nightly: {
      executor: 'ramping-arrival-rate',
      startRate: 0,
      timeUnit: '1s',
      preAllocatedVUs: 100,
      maxVUs: 1000,
      gracefulStop: '0s',      
      stages: [
        { target: Math.floor(100 / requestsPerIteration), duration: '5m' },
        { target: Math.floor(300 / requestsPerIteration), duration: '5m' },
        { target: Math.floor(200 / requestsPerIteration), duration: '5m' }
      ]
    }
  }
};

I assumed the above should start 2 iterations per second, then 6 iterations per second, and finally 4 iterations per second and by doing that achieve the expected RPS.

Did I misunderstand the options for this executor? Is ramping-arrival-rate the best executor for this use case?

Thanks.

Hi there,

you’re on the right track and the ramping-arrival-rate executor is a good fit for your use case.

What I think is confusing you is how the stages property is defined. Note that there’s a linear ramp up or down to reach the values you need. Since your startRate is 0, it will take the full duration of 5 minutes to reach the rate of 2 iters/s, so the first few minutes the throughput will be much less than that.

If you want an immediate change of throughput with no ramp up/down you can specify an additional step between each stage with a duration of 0s. For example:

    stages: [
      { target: Math.floor(100 / requestsPerIteration), duration: '0s' },
      { target: Math.floor(100 / requestsPerIteration), duration: '5m' },
      { target: Math.floor(300 / requestsPerIteration), duration: '0s' },
      { target: Math.floor(300 / requestsPerIteration), duration: '5m' },
      { target: Math.floor(200 / requestsPerIteration), duration: '0s' },
      { target: Math.floor(200 / requestsPerIteration), duration: '5m' }
    ]

This means that you will jump to 2 iters/s right away and sustain that throughput for the next 5 minutes. Then immediately jump to 6 iters/s, sustain, and so on.

1 Like

Thanks @imiric, I did misunderstand the stages property. I’ll try out your suggestion.