How to Run a New k6 Load Test
Run a new k6 Load Test with LoadFocus
Open the New k6 Test page (you need to be logged in), upload your k6 script, set the load and the locations, and click Run test. LoadFocus runs your script in the cloud with the stock k6 binary (v2.3.0).
Two kinds of script or target do not work with this k6 version. k6 extensions are not supported: a script that imports a k6/x/... module fails before it sends any load. And an HTTPS target that still uses TLS 1.2 and only accepts SHA-1 signatures fails the TLS handshake, so every request to it ends in an error (tls: handshake failure).
Steps to Configure a New k6 Load Test
The page has three numbered steps (1 Your test script, 2 How much load?, 3 Where from?), a More options section and a bar at the bottom with the run button.
1. Choose a Test Name
We automatically generate a test name using the current date and time. It sits at the top of the page, after New test:. Click the name or the pencil icon to change it. You can rename the test at any time.
2. Upload Your k6 Script
In step 1 Your test script, upload your k6 test script and the data files it reads. You can drag and drop files into the upload area or click Upload k6 Scripts & Files. A test can hold up to 10 files, each up to 100 MB. Accepted types:
.js: your k6 test script (required).ts: a TypeScript k6 script.csv,.json,.txt: data files your script reads withopen().env,.properties: configuration files
Only one script file runs per test, so bundle local modules into it (remote https:// modules are fine). For reading data files, see Uploading k6 scripts and data files. No script yet? Under the upload area, Import from cURL, HAR, Postman or OpenAPI turns an existing request into a k6 script (see Import to k6), and Describe it and let AI write it opens the AI test generator. See Create a load test with AI.
k6 Script Validation
LoadFocus checks your script when you upload it:
- It must be a
.jsor.tsfile with an entry point:export default function, orscenarioswhose entries name their function withexec. Without one the script is rejected. - Warnings, which do not block the test, point out a script with no
k6imports, nocheck()calls or nooptionsblock, one that uses__ENV, or one that imports a local file.
The check does not run your script, so a syntax error only shows up when the test runs.
Example k6 Script
import http from 'k6/http';import { check, sleep } from 'k6';export default function () {const res = http.get('https://test-api.k6.io/public/crocodiles/');check(res, {'status is 200': (r) => r.status === 200,'response time < 500ms': (r) => r.timings.duration < 500,});sleep(1);}
3. Load Presets
Step 2 How much load? starts with four presets:
- Quick check: a few users, to check it works.
- Typical: your everyday traffic.
- Peak: your busiest moments, to find the limit.
- Custom: set your own numbers below.
Each preset card shows the users and the total run time it sets, within the limits of your plan. Click one to fill in the configuration, then adjust it if you like.
4. Set the Load
Under the presets you define:
- Virtual Users: the number of concurrent virtual users to simulate.
- Duration (s): how long the test runs.
- Ramp-Up Time: how long it takes to reach the full number of virtual users.
Open Fine-tune for Ramp-Up Steps (the number of steps used to increase the load), for Run by iterations instead of time (a fixed number of iterations instead of a duration) and for Switch Time Units, which lets you enter the duration in minutes instead of seconds. The ramp-up chart shows how virtual users are added over the test, and the line under it sums up the run. The sliders stop at the limits of your plan. With iterations, the number is the total for the whole test, not per user: all virtual users start at once, the ramp-up is not used, and the users share the iterations (the line reads, for example, "10 users share 50 iterations in total, starting at once.").
On the Free plan, runs are also limited per day and per website: see Limits on the Free plan.
LoadFocus applies these values when it runs your script, so they replace any vus, duration or stages in the script's own options.
5. Load Distribution
In step 3 Where from?, choose the cloud locations the load comes from (Add Location adds another one). Each location gets a % Traffic value, and LoadFocus works out its Number of Users from your total. The percentages must add up to 100%. For example:
- US East (N. Virginia): 100% (10 users)
Running one test from several locations at once needs a Pro or Enterprise plan; other plans use one location. More details about the available locations can be found here.
6. More Options
Under More options you can add Pass/fail checks, Run on a schedule, and Send results to Datadog, New Relic…, which sends test metrics to an external monitoring tool: Datadog, New Relic, Dynatrace or OpenTelemetry. Click Manage integrations to set one up.
7. Run the Test
After configuring your load test and uploading your k6 script:
- Click Run test in the bar at the bottom of the page, then confirm in the Run this test? dialog. If something is missing, the bar says what after Can't run yet:.
- Click Save draft to save the configuration without running.
LoadFocus starts the cloud machines, runs your script, and streams results back while it runs. When it finishes, see Analyzing k6 load test results.