Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/using-k6/scenarios/executors/constant-vus.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/using-k6/scenarios/executors/constant-vus/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Constant VUs
With the constant-vus executor, a fixed number of VUs execute as many iterations as possible for a specified amount of time.
For a shortcut to this executor, use the VUs and duration options.
Options
Besides the common configuration options, this executor has the following options:
| Option | Type | Description | Default |
|---|---|---|---|
| duration(required) | string | Total scenario duration (excluding gracefulStop). | - |
| vus | integer | Number of VUs to run concurrently. | 1 |
When to use
Use this executor if you need a specific number of VUs to run for a certain amount of time.
Example
This examples schedules 10 VUs to run constantly for a duration 30 seconds.
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'constant-vus',
vus: 10,
duration: '30s',
},
},
};
export default function () {
http.get('https://test.k6.io/contacts.php');
// Injecting sleep
// Total iteration time is sleep + time to finish request.
sleep(0.5);
}Observations
The following graph depicts the performance of the example script:

Based upon our test scenario inputs and results:
- The number of VUs is fixed at 10, and are initialized before the test begins;
- Overall test duration is fixed at the configured 30 second duration;
- Each iteration of the
defaultfunction 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 see that the maximum throughput is reached and maintained for the majority of the test;
- Approximately 600 iterations are therefore performed in total,
30 seconds * 20 iters/s.
Was this page helpful?
Related resources from Grafana Labs

