Skip to main content

Test Options

Options control how k6 executes your test, including the number of VUs, test duration, thresholds, and more. Options can be set in multiple ways with a clear precedence order.

Setting Options

Options can be defined in three ways (in order of precedence):
  1. Command-line flags - Highest priority
  2. Environment variables
  3. Script options - Lowest priority

Basic Execution Options

Virtual Users and Duration

The simplest way to configure a test:

Iterations

Run a specific number of iterations instead of time-based:
With 10 VUs and 100 iterations, each VU will execute approximately 10 iterations.

Stages (Ramping)

Gradually ramp VUs up and down:
This creates an up-flat-down ramping profile:

Thresholds

Thresholds define pass/fail criteria for your test. If a threshold fails, k6 exits with a non-zero status code.

Threshold Expressions

Common threshold expressions:
Thresholds cause the test to fail when exceeded, unlike checks which only record pass/fail without affecting the test outcome.

HTTP Options

Request Limits

TLS/SSL Configuration

User Agent and Headers

Timeouts

Tags

Apply tags to all metrics in the test:

System Tags

Control which system tags are included with metrics:

DNS Configuration

Hosts Override

Map hostnames to IPs:

Blocked Hostnames

Prevent requests to specific hosts:

Blacklist IPs

Block requests to specific IP ranges:

Discard Response Bodies

Save memory by discarding response bodies:

Summary Configuration

Paused Mode

Start test in paused state:

Minimum Iteration Duration

Enforce a minimum time per iteration:

Complete Example

Here’s a comprehensive example combining multiple options:

Options Reference Table

Next Steps