Distributing 1000 unique requests across 100 vus

I have a requirement to hit the same endpoint for 1000 ids and I want to execute a single id only once. I could not develop a script that sends 100 requests in parallel, all unique ids.

Hi @sajag-incubyte

Welcome to the community forum :wave:

Do you have the IDs, for example, in a JSON or CSV file? If that is the case, you can use a Shared Array to retrieve the data, and then use the k6/execution module to pass the unique data via data parameterization. k6-learn has also a CSV example.

If you can’t apply this to your script, please share it (sanitized).


Thanks for the reply. It does solve for the issue partially. The solution proposed here uses math.random to pick the index. Is there a way to sequential run through the list and run each request just once.

Hello @sajag-incubyte in the post from @eyeveebe the documentation link provide contains this sample code which should make sequential requests.

see the data parameterization link. the const var_name=dat[scenario.iterationInTest] method is very useful

export default function () {
  // this is unique even in the cloud
  const user = data[scenario.iterationInTest];
  console.log(`user: ${JSON.stringify(user)}`);
1 Like

Thank you very much for this information. You saved me from spending a lot of time debugging and figuring this out.

1 Like