Unique test data per VU without reserving data upfront

Hi @niklasbae,

You basically need a shared integer that goes up between the VUs. This is unlikely (in that form) to be added to k6 but here is an k6 extension, that will help you.

As mentioned there (and in other places before) this can also be done through an external API that just returns you the next id and makes certain.

var element = array[parseInt(http.get("https://example.com/mynextid").body)]

Obviously with more checks and it also has the downside that this is one more request which takes time … but is actually portable to the cloud and to the future k6 distributed mode.

I would expect that if we ever have mutable state in k6 that is accessible from VUs it will be accessible based on something like a “group” of VUs. And in this way you can say that you want this counter to be accessible per each 500 VUs and k6 distributed mode will make certain that it chunks VUs between instances in such way.

This will also means that as long as you can run your whole test on a single instance you can also have exactly what you wanted. But also that if that isn’t possible (for resource reasons) you will get an error.