k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Documentation

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

What are options?

Options allows you to configure how k6 will behave during execution. Several of the options can be overridden by using command line flags and options.

Options are part of the script code so that they can be version controlled. The following JS snippet shows how to specify options:

import http from "k6/http";

export let options = {
  stages: [
    { duration: "1m", target: 10 },
    { duration: "1m" },
    { duration: "1m", target: 0 }
  ],
  thresholds: {
    http_req_duration: ["avg<100", "p(95)<200"]
  },
  tlsVersion: "tls1.2",
  userAgent: "MyK6UserAgentString/1.0"
};

export default function() {
  http.get("http://test.loadimpact.com/");
}

Available options

The table below details the available options that can be specified within a script. It also documents the equivalent command line flag or option when executing k6 run ... that can be used to override options specified in the code.

Option name
Option value

duration
or
--duration value or -d value

A string specifying the total duration a test run should be run for. During this time each VU will execute the script in a loop.

Default: null

Examples

export let options = {
    duration: "3m"
};

ext

An object used to set configuration options for third-party collectors (like plugins).

Default: null

Examples

This is an example of how to specify the test name (test runs/executions with the same name will be logically grouped together for trending and comparison purposes) when streaming results to Load Impact Insights.

export let options = {
    ext: {
        loadimpact: {
            name: "My test name"
        }
    }
};

insecureSkipTLSVerify
or
--insecure-skip-tls-verify

A boolean, true or false. When this option is enabled (set to true), all of the verifications that would otherwise be done to establish trust in a server provided TLS certificate will be ignored.

Default: false

Examples

export let options = {
    insecureSkipTLSVerify: true
};

iterations
or
--iterations value or -i value

A number specifying a fixed number of iterations to execute of the script, as opposed to specifying a duration of time during which the script would run in a loop.

Default: 1

Examples

export let options = {
    iterations: 10
};

linger
or
--linger or -l

A boolean, true or false, specifying whether the k6 process should linger around after test run completion. The primary use case for this is when making use of the k6 web UI.

Default: false

Examples

export let options = {
    linger: true
};

maxRedirects
or
--max-redirects value

The maximum number of HTTP redirects that k6 will follow before giving up on a request and erroring out.

Default: 10

Examples

export let options = {
    maxRedirects: 10
};

noConnectionReuse
or
--no-connection-reuse

A boolean, true or false, specifying whether k6 should reuse TCP connections when making requests.

Default: false

Examples

export let options = {
    noConnectionReuse: true
};

noUsageReport
or
--no-usage-report

A boolean, true or false. By default, k6 sends a usage report each time it is run, so that we can track how often people use it. If this option is set to true, no usage report will be made. To learn more, have a look at the Usage reports documentation.

Default: false

Examples

export let options = {
    noUsageReport: true
};

paused
or
--paused or -p

A boolean, true or false, specifying whether the test should start in a paused state. To resume a paused state you'd use the k6 resume command.

Default: false

Examples

export let options = {
    paused: true
};

stages
or
--stage value or -s value

A list of VU { target: ..., duration: ... } objects that specifies the target number of VUs to ramp up or down to for a specific period of time.

Default: based on vus and duration

Examples

The following config would have k6 ramping up to 10 VUs for 5 minutes, then staying flat at 10 VUs for 5 minutes before ramping down to 0 VUs for another 5 minutes.

export let options = {
    stages: [
        { duration: "5m", target: 10 },
        { duration: "5m" }
        { duration: "5m", target: 0 },
    ]
};

thresholds

A collection of threshold specifications to configure under what condition(s) a test is considered successful or not, when it has passed or failed, based on metric data. To learn more, have a look at the Thresholds documentation.

Default: null

Examples

export let options = {
    thresholds: {
        http_req_duration: ["avg<100", "p(95)<200"],
        "http_req_connecting{cdnAsset:true}":
["p(95)<100"]
    }
};

throw
or
--throw or -w

A boolean, true or false, specifying whether to throw errors on failed HTTP requests or not.

Default: false

Examples

export let options = {
    throw: true
};

tlsAuth

A list of TLS client certificate configuration objects. Each object needs to specify for which host(s)/domain(s) the given client certificate is valid for.

Default: null

Examples

export let options = {
    tlsAuth: [
        { domains: ["example.com"], 
          cert: open("mycert.pem"),
          key: open("mycert-key.pem") }

    ]

};

tlsCipherSuites

A list of cipher suites allowed to be used by in SSL/TLS interactions with a server. For a full listing of available ciphers go here.

Default: null (meaning all supported SSL/TLS cipher suites are allowed)

Examples

export let options = {
    tlsCipherSuites: [
        "TLS_RSA_WITH_RC4_128_SHA",
        "TLS_RSA_WITH_AES_128_GCM_SHA256",
    ]
};

tlsVersion

Either a string representing the only SSL/TLS version allowed to be used in interactions with a server, or an object specifying the "min" and "max" versions allowed to be used.

Default: null (meaning all supported SSL/TLS versions are allowed)

Examples

Specifying a specific version to allow:

export let options = {
    tlsVersion:  "tls1.2"
};

Specifying a min and max version to allow:

export let options = {
    tlsVersion: {
        min: "ssl3.0",
        max: "tls1.2"
    }
};

userAgent

String specifying the user-agent string to use in User-Agent headers when sending HTTP requests.

Default: Whatever Go sets, which as of this writing is "Go-http-client/2.0".

export let options = {
    userAgent: "MyK6UserAgentString/1.0"
};

vus
or
--vus value or -u value

A number specifying the number of VUs to run concurrently. If you'd like more control look at the stages option above.

Default: 1

export let options = {
    vus: 10
};

vusMax
or
--max value or -m value

A number specifying max number of virtual users, if more than vus. This option is typically used when the intent is to dynamically scale number of VUs up and down during the test using the k6 scale command. Since instantiating a VU is an expensive operation in k6 this options is used to preallocate vusMax number of VUs.

Default: 0

export let options = {
    vusMax: 10
};

Options