No results for

Powered byAlgolia

Shared iterations


In this executor, the iterations are shared between the number of VUs. The test ends once all iterations are executed. This executor is equivalent to the global vus and iterations shortcut options.

Iterations are not guaranteed to be evenly distributed with this executor. VU that executes faster will complete more iterations than slower VUs.

To guarantee that every VU completes a specific, fixed number of iterations, use the per-VU iterations executor.


Besides the common configuration options, this executor has the following options:

vusintegerNumber of VUs to run concurrently.1
iterationsintegerTotal number of script iterations to execute across all VUs.1
maxDurationstringMaximum scenario duration before it's forcibly stopped (excluding gracefulStop)."10m"

When to use

This executor is suitable when you want a specific amount of VUs to complete a fixed number of total iterations, and the amount of iterations per VU is not important. This will be the most "efficient" use of VUs, therefore if time to complete a number of test iterations is your concern, this executor should perform best.

An example use case could be to incorporate a quick performance test as part of the build cycle during development. As developers compile their changes, the test could be executed against the local code to help insure against performance regressions. This would be considered as part of "shifting left"; placing more emphasis on performance early in the development cycle when the cost of the fix is lowest.


In this example, we'll execute 200 total iterations shared by 10 VUs with a maximum duration of 30 seconds.

1import http from 'k6/http';
2import { sleep } from 'k6';
4export const options = {
5 discardResponseBodies: true,
6 scenarios: {
7 contacts: {
8 executor: 'shared-iterations',
9 vus: 10,
10 iterations: 200,
11 maxDuration: '30s',
12 },
13 },
16export default function () {
17 http.get('');
18 // We're injecting a processing pause for illustrative purposes only!
19 // Each iteration will be ~515ms, therefore ~2 iterations/second per VU maximum throughput.
20 sleep(0.5);


The following graph depicts the performance of the example script:

Shared Iterations

Based upon our test scenario inputs and results:

  • Test is limited to a fixed number of 200 iterations of the default function;
  • the number of VUs is fixed to 10, and are initialized before the test begins;
  • each iteration of the default function is expected to be roughly 515ms, or ~2/s;
  • maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, 2 iters/s * 10 VUs;
  • we then see that the maximum throughput is maintained for a larger portion of the test;
  • the 8 second test duration will be the shortest of all executor methods;
  • we know the distribution of iterations may be skewed; one VU may have performed 50 iterations, whereas another may have only performed 10.