How to set RPM for the test

Hi ,

Please help if there is any way to set RPM for tests.

Hi, welcome to the forum :slight_smile:

There are two ways you can set RPS (or RPM):

  • Using the arrival rate executors introduced in v0.27.0 you can define a constant or variable RPS per scenario, with the rate and timeUnit options.
    See the documentation for the constant and ramping arrival rate executors, this arrival rate explanation and this article for more information.

  • Using the old --rps option. This option is not as flexible as the arrival rate options, as it works globally and can only control the maximum RPS, so it cannot maintain a constant throughput. We recommend using arrival rate executors instead.

Thank you, I was looking for spike test with constant RPS, can you please help me with an example, actually I tried scenarios but scenarios are starting all at once

You can take a look at some of the examples on this page.

For a spike test with RPS you can use the ramping-arrival-rate executor with a specific stages configuration that holds a constant RPS for whatever time you need.

For example:

import http from 'k6/http';

export let options = {
  scenarios: {
    my_spike_test: {
      executor: 'ramping-arrival-rate',
      startRate: 10,
      timeUnit: '1s', // start at 10 iterations per second
      stages: [
        { target: 10, duration: '30s' },    // stay at 10 iters/s for 30s
        { target: 200, duration: '5s' },    // spike quickly to 200 iters/s
        { target: 200, duration: '3m30s' }, // hold at 200 iters/s for 3.5 minutes
        { target: 10, duration: '5s' },     // scale down quickly to 10 iters/s
        { target: 10, duration: '30s' },    // hold at 10 iters/s over the last 30 seconds
      preAllocatedVUs: 50, // how large the initial pool of VUs would be
      maxVUs: 100,         // if the preAllocatedVUs are not enough, we can initialize more
      exec: 'spiketest',   // arbitrary exported function name to execute

export function spiketest() {
  // Just make a request here. It's important to not introduce any sleep or
  // additional processing here to ensure iters/s matches RPS.

actually I tried scenarios but scenarios are starting all at once

You can use the startTime option to delay certain scenarios, see the documentation.
For a simple spike test you likely only need one scenario anyway, but support for chaining scenarios dynamically is being considered in #1342.

Thank you imiric ,but iterations are not same as number of requests right, also to separate prereq requests for which metrics are not required, Iam separating them using thresholds. So does the metric value displayed above threshold entry is the total of prereq+main req or is it only for prereq.

If your iterations have only a single request, they are. Or if they have more, you can calculate them accordingly…

not sure what exactly you mean by prepreq, but consider using setup() or a separate scenario for them?