The VU metric shows a smaller number than what I've configured

I have a question about vus metric.

I saw this documentation already but I’m still curious about it.

I set the number of vus to a certain number. But, even though it’s fixed, sometimes the value of the vus is less than the number I set.
I wonder if the number of vus is guaranteed or not.

[Result Image]
Situation: I set the vus to 10. But in the result, vus is 6.

I set my options like this.

export let options = {
  vus: 10,
  duration: '10s'
}

I am looking for a tool to test a large amount of web socket clients, so it is important that the number of user is guaranteed.

By the way, k6 is well documented and I think it’s really good.
Thanks a lot :blush:!!

Hey @Erin,

k6 adjusts the VUs based on various criteria, including the endpoint response time, network throughput, and other related latencies. But, if you want to generate a constant request rate, have a look at my article:

How to generate a constant request rate in k6 with the new scenarios API?

1 Like

In your particular case @Erin there will always be 10VUs for the duration of the test. After the 10s(your duration) though because after v0.27.0 we have gracefulStop of 30s by default we will wait for VUs to finish their already started iterations for 30s. This means that some VUs will return before others(arguably this is always the case … even if we stop them “simultaneously” without gracefulStop).

Now unfortunately in this case (and I think this is the only such case at all …) vus is a counter which increases and decreases (see stages/ramping-vus, for an example of this), k6 actually stops all VUs at the end and that counter does go down to 0.

Unfortunately, it seems that the “all VUs have stopped we can print the summary now” and “all VUs have stopped and we have updated the counters and that have gone through so it will be seen in the summary” are two distinct events, that lead to the vus last value (which shown here) to not be 0 as it should be … as at the end of a test we have always stopped all vus.

tl;dr - in your particular case it was 10 vus for the whole duration you care about :wink:

Hope this answers your question

3 Likes

@mostafa
Thanks for letting me know. :relaxed:

1 Like

@mstoykov
Thank you for your kind explanation!
I got it now. :blush: