Kindly asking for your advice. I noticed that my k6 script with Ramping arrival rate sends much more requests than it should. I set following stages:
import http from 'k6/http';
export const options = {
scenarios: {
contacts: {
executor: "ramping-arrival-rate",
startRate: 0,
timeUnit: "1s",
preAllocatedVUs: 1,
maxVUs: 50,
stages: [
{ target: 10, duration: '30s' }, // Ramp Up
{ target: 10, duration: '3m' }, // Keeping load level
{ target: 1, duration: '30s' }, // Ramp Down
],
},
},
};
export default function () {
const res = http.get(`https://mywebsite.com`);
}
I expected to receive 10 rps load with these settings, but in fact I got 40 rps.
Grafana metrics screenshot |
k6 report screenshot
So I tried to use another arrival instead and created easy test plan with Constant arrival rate
import http from 'k6/http';
export const options = {
scenarios: {
contacts: {
executor: 'constant-arrival-rate',
rate: 10,
timeUnit: '1s',
duration: '1m',
preAllocatedVUs: 5,
maxVUs: 50,
},
},
};
export default function () {
const res = http.get(`https://mywebsite.com`);
}
I ran K6 with this script and received the same picture again: 10 iterations per second, but 40 requests per second.
Grafana metrics screenshot |
k6 report screenshot
I also tried to add sleep to default function but it didn’t help.
Why does this happen? How can I make k6 make load level exactly 10 rps?
It would be perfect if k6 would load my website with needed rps and if stages would work too.
Александр Костюк is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Found the reason of this issue.
This script cauches redirects and each redirect is counted as a new rps.
So my test has 10 iterations per second and at the same time 40 requests per second.
Ways to solve it:
- Add maxRedirects: 0
- Count iterations in grafana dashboard instead http requests.
Александр Костюк is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2