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    Guides

Load Impact Insights

Insights introduction

Load Impact offers a SaaS solution for k6 results storage, analysis and trending. It is called Load Impact Insights. Insights allows you to run your load tests locally using k6 while streaming your results to loadimpact.com where you can look at the test in real time and also perform detailed results analysis.

As part of its SaaS solution, Load Impact also offers distributed execution from the cloud, to run larger and/or geographically distributed tests.

_Load Impact Insights screenshot_

Load Impact Insights screenshot

This means you can run your own load generator and test internal systems, but benefit from a more powerful and convenient SaaS solution when you want to store, share and analyze test results. You can utilize the loadimpact.com cloud to execute tests (but such tests will require that the target system is reachable from the public Internet).

Getting started with k6 and Load Impact Insights

  • First you need to create a loadimpact.com account

  • Once logged in, switch to the project named "k6 project" (we currently have two cloud offerings, one based on Lua scripting and cloud execution and Insights based on streaming/uploading k6 test results).

  • Next, you need to start a 14 day Trial.
  • Follow the instructions on screen to get k6 installed and setup for steaming test results.

If you have already installed k6 you only need to make sure you have it configured with access to your Load Impact API token. You do that by either running k6 login cloud and entering your Load Impact account details or you set the K6_CLOUD_TOKEN to your API token value.

Don't forget to add -o cloud to specify that you want the test results streamed to Insights!

K6CLOUD_TOKEN is now K6_CLOUD_TOKEN

Starting with v0.18.0 K6CLOUD_TOKEN has been renamed K6_CLOUD_TOKEN. The old spelling will still work in v0.18.0 but a deprecation message will be printed to the terminal.

K6_CLOUD_TOKEN=c3b391149764640ed7d51476cd34a947f0d0762552a5bae79ee10b07ee84c1f7 k6 run -o cloud script.js
docker run -i -e "K6CLOUD_TOKEN=c3b391149764640ed7d51476cd34a947f0d0762552a5bae79ee10b07ee84c1f7" loadimpact/k6 run -o cloud - <script.js

Now your test should be running, and results should be streamed live to loadimpact.com. k6 will output something like this when it starts:

As you can see in the screen shot above, k6 will tell you that you can use the URL https://app.loadimpact.com/k6/runs/179 to go directly to the test result/analysis page where results will be updated continuously throughout the test.

Streaming results to a project other than the default one

Note that your API token is scoped to a specific organization

If you are part of more than one Load Impact organization you need to generate an API token for each organization as the API token is currently per-organization. You can do this by first switching to the specific organization using the organization/project switcher in the left sidebar and then clicking on "Integrations" in the left sidebar menu (ending up on this page).

By default tests and test runs will be created and run under your default project, in your default organization. To create and run tests under a different project, whether under your default organization or one you've been invited to, you have two options:

1. You can specify the project ID in the script options:

export let options = {
  ext: {
    loadimpact: {
      projectID: 123456
    }
  }
}

2. You can set the K6_CLOUD_PROJECT_ID environment variable when running the test.

You find the ID of a Load Impact project by selecting a k6 project in the UI and looking in the URL bar of your browser, the 12345 in https://app.loadimpact.com/projects/12345/dashboard is the project ID.

Insight service run states

When you run a k6 test run against Load Impact Insights, data will be continuously streamed to the cloud. While this happens the test's run state will be marked as Running. A test run that ran its course will be marked Finished. The run state has nothing to do with the test passing any of its checks, only that the test itself is operating correctly.

If you deliberately abort your test (e.g. by pressing Ctrl-C), it will still be considered Finished by Insights. You can still look and analyze the test data you streamed so far. The test will just have run shorter than originally planned.

Another possibility would be if you lose network connection with Load Impact Insights while your test is running. In that case Insights will patiently wait for you to reconnect. In the meanwhile your test's run state will continue to appear as Running on the Insights web overview. If no reconnection happens, Insights will time out after two minutes of no data, setting the run state to Timed out. You can still analyze a timed out test but you'll of course only have access to as much data as was streamed before the network issue.

Aggregation

Since version 0.21, k6 supports partial aggregation of metrics streamed to Load Impact Insights for reduced bandwidth usage and processing times. To enable this, set the environment variable K6_CLOUD_AGGREGATION_PERIOD to the aggregation period you want, for example 1s. If there are more than a certain number of HTTP metrics for a period (100 by default, but it can be modified by setting K6_CLOUD_AGGREGATION_MIN_SAMPLES), they are partially aggregated. It is important to note that outlier metrics are automatically detected and sent separately, they are never aggregated.

Cloud/Distributed execution

Load Impact also offers a commercial cloud service for distributed execution of k6 tests. See the Cloud execution (public beta) page for more information.

More information