- Documentation
- Learning Hub
- Module 2 of 4 Your first performance test
How k6 runs your test script
Slide 2 of 6
How k6 runs your test
Virtual users (VUs) run your default function in parallel loops without shared variables. One iteration is one full run of default by one VU. Duration or stages decide how long VUs keep looping.
Three parts of a k6 script
A k6 script has up to three parts. In the first learning path, you only use options and the default function.
Minimal example
export const options = {
vus: 10,
duration: '30s',
thresholds: {
http_req_duration: ['p(95)<500'],
},
};
export default function () {
http.get('https://quickpizza.grafana.com');
sleep(1);
}options— how hard you push, for how long, and what pass or fail means for the run.default— what each virtual user does each iteration: requests and checks.setup/teardown(optional) — one-time shared prep and cleanup, for tokens or test data. Refer to Test lifecycle when a later script needs them.