How to pick/get users in sequence(0,1,2..) from JSON files?

I have credentials(email and password) in the JSON file and I want to get those credentials in sequence. let’s say I have 100 VUS in JSON file, so now I want to load the first 50 VUS for 5s and the rest 50 VUS for another 10s.

But right now I am getting users randomly. sometimes one user completes 2 iterations while some haven’t iterate once.

I have this code

Hi there,

one approach you could use is to separate your test in two scenarios, each with 50 VUs, with one scenario running first and the other one after, using the startTime option.

Selecting a unique JSON object per VU is a bit tricky, but doable with this approach.

However, selecting objects sequentially is even trickier since you can run the test with arbitrary VUs and iterations, and you’d need some centralized way to increment the index. For this I’d recommend considering the xk6-counter extension, for which you’ll need to compile your own k6 binary using xk6. Otherwise you could also use Redis for this purpose, using one of the Redis extensions, or even over HTTP with Webdis. You’ll need to use the Redis INCR command, but it should be relatively straightforward.

Thank you for the quick response.

I am using the first approach(Scenario one), so do I have to use a different JSON file(credential) for each scenario.