No results for

Powered byAlgolia

Constant VUs

Description

A fixed number of VUs execute as many iterations as possible for a specified amount of time. This executor is equivalent to the global vus and duration options.

Options

In addition to the common configuration options this executor also adds the following options:

OptionTypeDescriptionDefault
duration(required)stringTotal scenario duration (excluding gracefulStop).-
vusintegerNumber of VUs to run concurrently.1

When to use

Use this executor if you need a specific amount of VUs to run for a certain amount of time.

Example

In this example, we'll run 10 VUs constantly for a duration 30 seconds.

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

Observations

The following graph depicts the performance of the example script:

Constant VUs

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 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 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.