Like unit testing, for performance

k6 is a developer-centric open source load testing tool for testing the performance of your backend. It’s built with Go and scriptable in ES6 JS and integrates well into your development and automation workflow, so you can stay on top of performance without fuzz.

Why we built k6

Why we built k6 and how it fits into our goals with our next generation service

Developer-centric

We wanted an open source developer-centric load testing tool with flexible and powerful scripting, modern command line UX and good automation support. We didn't find such a tool available on the market, so we built k6.

Open source and community

We believe great developer tools should be open source and come with great documentation, allowing for a community to form around the tool. Visit the Github repo to see the code, roadmap and issues.

Automation native

k6 is built to integrate into your development environment as well as your CI or automation environment. That's why k6 is a command-line tool with features like custom metrics, checks (like asserts) and thresholds as well as several result output options.

Run performance tests from anywhere

Your test scripts work unchanged across single and multi machine (cloud) execution

k6 CLI

Your computer

Run tests from your local machine to test debug a script or to get quick performance feedback before pushing code to version control and CI.

Self-managed

Run tests from on-premise machines or cloud servers under your own AWS, Azure or GCP account.

Managed, globally distributed (beta)

For convenience or to scale out, you can move your scripts without changes to run on Load Impact's global cloud infrastructure.

Based on familiar and powerful ES6 JavaScript

Modules

Create ES6 JS modules that can be reused across tests and teams to build a foundational performance testing library for your organization.

Checks and Thresholds

Checks (like asserts) are used to validate functional aspects of your test. Thresholds is the essential feature that you use to specify the pass/fail criteria of your tests. You can create thresholds based on any of the standard metrics collected by k6, as well as any custom metrics that you define.

HTTP/1.1, HTTP/2 and WebSocket

Ready for the present and future k6 supports performance testing systems that talk HTTP/1.1 HTTP/2 and WebSocket.

Batteries included standard library

Besides the standard ES6 JS APIs, k6 comes bundled with APIs to handle Cookies, Crypto, Encodings, Environment variables, HTML forms, HTML parsing, Multipart requests, TLS client certificates, TLS ciphers & versions and more.

script.js

import http from "k6/http";
import { group, sleep, check } from "k6";

// Get login credentials from env vars
let email = __ENV.EMAIL;
let password = __ENV.PASSWORD;

export default function() {
    // Login to get API session token
    let res = http.post("https://api.loadimpact.com/v3/account/login",
        JSON.stringify({ email: email, password: password }),
        { headers: { "Content-Type": "application/json" } }
    );

    sleep(1);

    // Extract API session token from JSON response
    let apiToken = res.json().token.key;

    // Use session token to make API requests
    res = http.get("https://api.loadimpact.com/v3/account/me",
        { headers: { "Authorization": "Token " + apiToken } }
    );
    check(res, {
        "status is 200": (res) => res.status === 200,
        "content-type is application/json": (res) => res.headers['Content-Type'] === "application/json",
        "content OK": (res) => JSON.parse(res.body).hasOwnProperty('organizations')
    });

    sleep(3);
}

Easy, platform native installation flow

 

  1. Download the latest k6 binary:
    $ curl -OL https://github.com/loadimpact/k6/releases/download/v0.20.0/k6-v0.20.0-linux64.tar.gz
  2. Unzip and put binary somewhere in your $PATH:
    $ tar -xzf k6-v0.20.0-linux64.tar.gz
    $ cp k6-v0.20.0-linux64/k6 /usr/local/bin
    
  3. Run your first k6 test:
    $ k6 run -u 1 -d 10s github.com/loadimpact/k6/samples/http_get.js
  1. Install k6 using Homebrew:
    $ brew tap loadimpact/k6
    $ brew install k6
  2. Run your first k6 test:
    $ k6 run -u 1 -d 10s github.com/loadimpact/k6/samples/http_get.js
  1. Download the latest k6 binary from Github.
  2. Unzip and put binary somewhere in your PATH
  3. Run your first k6 test:
    $ k6 run -u 1 -d 10s github.com/loadimpact/k6/samples/http_get.js

Integrate into your automation pipelines

Whether you run your tests from a machine that you manage or from the Load Impact cloud service you can easily integrate performance tests into your favorite CI tool like CircleCI, GitlabCI, TravisCI, JenkinsCI and TeamCity.