Skip to main content

Options reference

Options configure test-run behavior. Use options to define test tags, thresholds, user agents, the number of virtual users and iterations, and much more.

How to use options

You can set options in multiple places with different levels of precedence:
1

In the script

Use the export const options object to set default options in your script.
2

Command-line flags

Override script options with CLI flags.
3

Environment variables

Use environment variables with the K6_ prefix.

Order of precedence

When you set options in multiple places, k6 applies them in this order (highest to lowest precedence):
  1. Command-line flags
  2. Environment variables
  3. Script options
  4. Default values

Common options

Virtual users and duration

integer
default:"1"
Number of virtual users to run concurrently.
string
default:"null"
Total test duration. The test will run for this duration with the specified number of VUs.
integer
default:"1"
Total number of iterations to execute across all VUs.

Stages

array
default:"[]"
Ramp VUs up or down during the test.

Thresholds

object
default:"{}"
Pass/fail criteria for metrics.

Scenarios

object
default:"{}"
Advanced configuration for VU and iteration scheduling.

Complete options list

Here’s the complete list of k6 options:

Execution options

  • vus - Number of virtual users
  • duration - Test duration
  • iterations - Total iterations
  • stages - VU ramping configuration
  • scenarios - Advanced scenario configuration
  • executionSegment - Segment of test to run
  • executionSegmentSequence - Sequence for segmentation

HTTP options

  • batch - Max parallel requests in batch
  • batchPerHost - Max parallel requests per host
  • httpDebug - HTTP request/response logging
  • insecureSkipTLSVerify - Skip TLS verification
  • tlsAuth - TLS client certificate configuration
  • tlsCipherSuites - TLS cipher suites
  • tlsVersion - Min/max TLS versions

Output options

  • noConnectionReuse - Disable keep-alive
  • userAgent - User-Agent header value
  • discardResponseBodies - Don’t save response bodies
  • rps - Max requests per second

Lifecycle options

  • setupTimeout - Setup function timeout
  • teardownTimeout - Teardown function timeout
  • maxRedirects - Max HTTP redirects

Tags

  • tags - Tags applied to all metrics
  • systemTags - System tags to collect

Console output

  • noVUConnectionReuse - Per-VU connection behavior
  • minIterationDuration - Minimum iteration duration
  • maxDuration - Maximum test duration

Examples

Load test with ramping

Spike test

Using environment variables

Test lifecycle

Learn about the test execution lifecycle

Scenarios

Advanced VU and iteration scheduling

Thresholds

Set pass/fail criteria for your tests

Environment variables

Using environment variables in k6