No results for

Powered byAlgolia

Constant arrival rate

suggest edits

Description

A fixed number of iterations are executed in a specified period of time. Since iteration execution time can vary because of test logic or the system-under-test responding more slowly, this executor will try to compensate by running a variable number of VUsincluding potentially initializing more in the middle of the testin order to meet the configured iteration rate. This approach is useful for a more accurate representation of RPS, for example.

See the arrival rate section for details.

Options

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

OptionTypeDescriptionDefault
duration*stringTotal scenario duration (excluding gracefulStop).-
rate*integerNumber of iterations to execute each timeUnit period.-
preAllocatedVUs*integerNumber of VUs to pre-allocate before test start in order to preserve runtime resources.-
timeUnitstringPeriod of time to apply the rate value."1s"
maxVUsintegerMaximum number of VUs to allow during the test run.-

When to use

When you want to maintain a constant number of requests without being affected by the performance of the system under test.

Examples

In this example, we'll execute a constant rate of 200 RPS for 1 minute, allowing k6 to dynamically schedule up to 100 VUs.

constant-arr-rate.js
1import http from 'k6/http';
3export let options = {
4 discardResponseBodies: true,
5 scenarios: {
6 contacts: {
7 executor: 'constant-arrival-rate',
8 rate: 200, // 200 RPS, since timeUnit is the default 1s
9 duration: '1m',
10 preAllocatedVUs: 50,
11 maxVUs: 100,
12 },
13 },
14};
16export default function () {
17 http.get('https://test.k6.io/contacts.php');
18}

Note that in order to reliably achieve a fixed request rate, it's recommended to keep the function being executed very simple, with preferably only a single request call, and no additional processing or sleep() calls.