Good morning, is it possible to control VU’s actions individually when I run k6 run script.js?
I am not sure what exactly you mean by “control”, but I think the answer to your question is yes In k6, each virtual user (VU) is an independent JavaScript runtime executing whatever you specify in your script. So, in principle, each VU can run completely different code.
You can use the __VU
and __ITER
execution context variables to distinguish between VUs in your code with some if
checks, though they are more commonly used to parametrize some data sent to the server. Math.random()
can also be used for some stochastic branching or parametrization.
In recent k6 versions, can also use the scenarios
functionality to more easily have your load test execute multiple different journeys in parallel and/or at the same time.