Is there a way I could set number of VUs to spread across 16h for example?

Currently I have to test some application where user wants to see 10000 VUs accross 16h, like normal business day with peaks and downs ofc, how should I approach this?

I would be grateful if u could make some points/examples.

Thank you in advance!

Ooft. This would be my suggestion: Ramping VUs

There are examples there, but if not:

import http from "k6/http";
import { sleep, check } from "k6";

export let options = {
  stages: [
    { duration: "2h", target: 10 },     // Ramp up to 10 VUs over 2 hours
    { duration: "10h", target: 10 },    // Stay at 10 VUs for 10 hours
    { duration: "2h", target: 0 },      // Ramp down to 0 VUs over 2 hours
  ],
  thresholds: {
    http_req_duration: ["p(95)<500"],  // Set performance thresholds as needed
  },
  ext: { // Can bin all this off if you don't use K6 Cloud
    loadimpact: {
      distribution: {
        "amazon:us:portland": { loadZone: "amazon:us:portland", percent: 100 },
      },
    },
  },
};

export default function() {
  let res = http.get("http://loadtestfor14h.com/");
  check(res, {
    "status is 200": (r) => r.status === 200,
  });
  sleep(1);
}

In this example, the test will ramp up to 10 VUs over a period of 2 hours, then stay at 10 VUs for 10 hours, and finally ramp down to 0 VUs over 2 hours. You can adjust the duration and target values in the stages array to suit your needs. You can add more stages, I just used 3 as an example.

1 Like