K6 script with Each VUS hit 10 request per seconds

Hello please help me, i still confused about constant-arrival-rate thing. If i want to have 600 Virtual Users, and each Virtual Users hit the endpoint with 10 requests per 1 seconds, the duration is 1 minutes. How do i make the script? does the script below is true?

export const options = {
  scenarios: {
    constant_request_rate: {
      executor: 'constant-arrival-rate',
      rate: 10,
      timeUnit: '1s', 
      duration: '1m',
      preAllocatedVUs: 100, 
      maxVUs: 600, 
    },
  },
};

Is that script have each virtual users hit endpoint with 10 request per 1 seconds? if not, please help me.

Hi @daus2936

Welcome to the community forum :wave:

The following docs can help explain some scenario concepts that are relevant to your question:

If you decide to go for an open model like constant-arrival-rate, to make sure the endpoint gets N requests per second (the usual scenario when load testing APIs, k6 will adjust the number of virtual users needed.

As per the calculations, if you need 600 “users” x 10 requests per second, you would have to define a rate of 6000, with the timeUnit of 1s. That is, you want the endpoint to receive 6000 requests per second. k6 will use the virtual users required up to maxVUs.

It’s best to adjust preAllocatedVUs so you start the test with the number of VUs you will need for that rate, which you can find some help calculating in Arrival-rate VU allocation.

If you need the endpoint to receive 10 requests per second, your example would probably achieve that (if your system under test is responsive enough so the 600 maxVUs are enough for 10rps). I was not sure what rate do you actually need in the endpoint.

The first thing is to decide what you really need to simulate. If you fixed the number of users to 600, with a constant-vus, you would not be able to guarantee the 10 requests per second. As this would depend on how the system under test responds.

If you need to generate a constant arrival rate, focus on the rate and time unit needed at the endpoint (10 rps or 6000 rps?) and explore how many VUs you will need based on your iteration duration. And define those as preAllocatedVUs.

I hope this helps.

Cheers!

Cheers!

Thank you very much, this is what i need.

1 Like