Let me apologies in advance is someone has asked this question already and I missed it in my searches. But I am trying to understand how VU’s work with regards to the code in the default function, and how that might affect requests when using batch.
From what I have read, I am getting the impression that if I run my script with --vus 2, then all of the code in the default function will be run by two separate VU’s. Am I correct in my understanding?
The problem I am having is that the code that I have written has roughly three parts to it, a create, update and delete. I can choose the number of updates that take place using environment variables. On top of this, the code is reading an input file that contains a list of ID’s, so each part of the test (create, update, delete) uses these ID’s to build an array of requests, which is then passed into the batch function.
So, am I to understand that using more than one VU means that the batch statement will be executed n times, n being the number of VU’s? I am trying to understand this because I need to ensure that each request in the batch is only sent once.
Any guidance or point in the right direction would be greatly appreciated. **Disclaimer - I am a noob at k6 and java script…if you haven’t already guessed it.
This makes things a bit complicated. k6 has the __VU and __ITER execution context variables, to potentially allow you to choose non-overlapping portions of that array for different VUs. Depending on the complexity of your use case, that might or might not be enough, so we’re working on an even more flexible API that would hopefully land soon.
This seems to work pretty good, however I need to debug an issue that seems to increment one of my counters incorrectly. For some reason, even though I set numberOfSubscribers to say 10…its incrementing well into 13. sooo…time for some strategic “console.log” to debug this.