Skip to content

Conversation

mstoykov
Copy link
Contributor

What?

Add an example for data parametreziation where neither VU nor iterations are set specifically to the numbert of data available but insted we use a modulo operator.

This arguably is the most common case IME.

Checklist

  • I have used a meaningful title for the PR.
  • I have described the changes I've made in the "What?" section above.
  • I have performed a self-review of my changes.
  • I have run the npm start command locally and verified that the changes look good.
  • I have made my changes in the docs/sources/k6/next folder of the documentation.
  • I have reflected my changes in the docs/sources/k6/v{most_recent_release} folder of the documentation.
  • I have reflected my changes in the relevant folders of the two previous k6 versions of the documentation (if still applicable to previous versions).
  • I have made my changes in the docs/sources/k6/next folder of the documentation.

Related PR(s)/Issue(s)

@mstoykov mstoykov requested review from heitortsergent and a team as code owners September 19, 2025 16:41
@mstoykov mstoykov requested review from ankur22 and codebien and removed request for a team September 19, 2025 16:41
@heitortsergent heitortsergent changed the title data parametrization example wiht module operator Data parameterization example with module operator Sep 19, 2025
@mstoykov mstoykov requested review from dgzlopes and a team September 19, 2025 16:44
Copy link
Contributor

Comment on lines +251 to +253
Or if you have a big data set and just want no VU to use any data any other VU. But you want to have a set number of VUs. In that case you can use modulo operator to get a user out of the data set for each VU so no other ones does.

This also allows us to loop over the data set while still making certain no two VUs will use the same data at the same time. Or during the test for that matter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Suggested change
Or if you have a big data set and just want no VU to use any data any other VU. But you want to have a set number of VUs. In that case you can use modulo operator to get a user out of the data set for each VU so no other ones does.
This also allows us to loop over the data set while still making certain no two VUs will use the same data at the same time. Or during the test for that matter.
If you have a large dataset and want to make sure no two VUs use the same value in the data set at the same time (while keeping a fixed number of VUs), use the modulo operator with the global iteration index. This gives you a round-robin assignment over the dataset and avoids collisions during a run.

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants