k6 Load Testing Interview Questions for Beginners (2027)
46 k6 interview questions for beginners: load test types, VUs, iterations, checks, thresholds, metrics, scenarios, executors and CI basics with answers.
k6 interview questions for beginners test whether you understand load testing itself (test types, percentiles, open and closed models) and the basics of k6: virtual users, iterations, the test lifecycle, checks versus thresholds, built-in metrics, stages and scenarios, and how a k6 run fails a CI build. This page has 46 numbered questions, with 24 fresher questions first, then practical, senior and scenario questions.
For the full question bank across all levels, see 65+ k6 interview questions. For engineer-level depth, read k6 engineer interview questions.
Key takeaways
- Know the six test types k6 documents: smoke, average-load, stress, soak, spike and breakpoint.
- A VU is a looping simulated user; an iteration is one run of the default function.
- Checks record results but never fail a test; thresholds fail the run and set a non-zero exit code.
- Read percentiles such as p(95), not averages.
- Arrival-rate executors model open traffic; ramping-vus and constant-vus are closed models.
- Only test systems you own or have written permission to test.
Freshers: performance testing and k6 basics (questions 1 to 24)
1. What is load testing?
Load testing sends realistic traffic to a system to see how response time, error rate and resource use behave at expected and higher volumes. It answers whether the system meets its performance goals before users find out.
2. What is the difference between performance, load and stress testing?
Performance testing is the umbrella term. Load testing checks behaviour at expected traffic. Stress testing pushes past expected traffic to find how and where the system degrades.
3. Which test types does the k6 documentation describe?
| Type | Purpose |
|---|---|
| Smoke | Minimal load to check the script and system work |
| Average-load | Normal production traffic |
| Stress | Above-average load |
| Soak | Average load for hours, to find leaks and slow degradation |
| Spike | A sudden, short surge |
| Breakpoint | Increase load until the system fails |
4. What is k6?
k6 is an open source load testing tool maintained by Grafana Labs. Tests are written in JavaScript (and TypeScript), and the engine is written in Go, so one machine can simulate many users with modest resources. Version 1.0 was released in 2025.
5. Why is k6 popular with DevOps teams?
Tests are code that lives in Git, the CLI runs anywhere including CI, pass and fail criteria are defined as thresholds, and results can stream to Prometheus, Grafana and other backends.
6. What is a virtual user (VU)?
A VU is an independent loop that runs your test function again and again, like one simulated user. Each VU has its own JavaScript runtime and state, such as cookies.
7. What is an iteration?
One complete run of the default function by one VU. The number of iterations per second depends on how long each iteration takes, including any sleep.
8. Write the smallest useful k6 script.
import http from "k6/http";
import { check, sleep } from "k6";
export const options = {
vus: 10,
duration: "30s",
};
export default function () {
const res = http.get("https://test.k6.io");
check(res, { "status is 200": (r) => r.status === 200 });
sleep(1);
}Run it with k6 run script.js. test.k6.io is the demo site Grafana provides for practice; never point a load test at a system you do not own or have permission to test.
9. What are the four stages of the k6 test lifecycle?
Init code (top level, runs once per VU, used to import modules and load files), setup() (runs once before the test), the default or scenario function (runs per iteration) and teardown() (runs once after). Data returned by setup is passed to the others.
10. Why can you not make HTTP requests in init code?
Init code runs for every VU before the test starts and is meant for preparation. k6 blocks HTTP calls there. Put one-off requests, such as getting a token, in setup().
11. What is the difference between checks and thresholds?
A check is an assertion that records pass or fail but does not stop or fail the test. A threshold is a pass or fail rule on a metric, such as p(95)<500; if it fails, k6 exits with a non-zero code so CI can fail the build.
12. Show a threshold block.
export const options = {
thresholds: {
http_req_failed: ["rate<0.01"],
http_req_duration: ["p(95)<500", "p(99)<1000"],
checks: ["rate>0.99"],
},
};
13. What are stages?
A shortcut that ramps the number of VUs over time, for example up to 50 over two minutes, hold for five, then down to zero. It maps to the ramping-vus executor.
14. Which built-in HTTP metrics should you know?
http_req_duration (total request time), http_req_failed (rate of failed requests), http_reqs (count), and timing parts such as http_req_waiting (time to first byte), http_req_connecting and http_req_tls_handshaking. General metrics include vus, iterations and data_received.
15. What metric types does k6 have?
Counter (sums values), Gauge (keeps the latest value), Rate (percentage of non-zero values) and Trend (statistics such as average and percentiles). Custom metrics use the same four types from k6/metrics.
16. Why look at percentiles instead of averages?
Averages hide slow outliers. The 95th percentile tells you what the slowest 5 percent of users experience, which is closer to how people judge an app. Most performance goals are written as percentiles.
17. What does sleep do in a k6 script?
It pauses the VU to model user think time. Without it, each VU sends requests as fast as possible, which is useful for some API tests but does not look like real users.
18. What are tags and groups?
Tags are labels on requests and metrics (k6 adds some, like status and method; you can add your own) used to filter results and set thresholds per tag. Groups bundle requests under a name, such as a page or transaction, in the results.
19. How do you read the end-of-test summary?
Look first at thresholds (passed or failed), then http_req_failed, then the http_req_duration percentiles, then iterations per second to confirm the load you meant to produce actually happened.
20. How do you load test data such as user lists?
Read files in init code with open() and wrap the parsed data in a SharedArray so it is loaded once and shared read-only across VUs instead of copied into each.
21. What are k6 extensions?
Go modules that add features, such as new protocols or outputs, built into a custom k6 binary with the xk6 tool. Use them when the built-in modules do not cover what you need.
22. Can k6 test browsers as well as APIs?
Yes. The k6/browser module drives a Chromium browser to measure front-end metrics such as Web Vitals. Browser VUs are much heavier than protocol VUs, so most tests mix many HTTP VUs with a few browser VUs.
23. Which protocols does k6 support besides HTTP?
WebSockets, gRPC and HTTP/2 are built in. Others, such as Kafka or SQL databases, come through extensions.
24. Where can k6 send results?
To the terminal summary, JSON or CSV files, and real-time outputs such as Prometheus remote write, InfluxDB and Grafana Cloud k6, using --out. A custom summary can be produced with the handleSummary() function.
2 to 5 years: realistic tests (questions 25 to 36)
25. What are scenarios and executors?
Scenarios let one test run several workloads with different settings; each scenario uses an executor that decides how VUs and iterations are scheduled. Executors include shared-iterations, per-vu-iterations, constant-vus, ramping-vus, constant-arrival-rate, ramping-arrival-rate and externally-controlled.
26. What is the difference between closed and open models?
In a closed model (constant-vus, ramping-vus) a VU starts its next iteration only after the previous one finishes, so a slow system receives less load. In an open model (arrival-rate executors) k6 starts iterations at a fixed rate whatever the response time, which matches public traffic better.
27. Show a constant arrival rate scenario.
export const options = {
scenarios: {
checkout: {
executor: "constant-arrival-rate",
rate: 50,
timeUnit: "1s",
duration: "5m",
preAllocatedVUs: 100,
maxVUs: 300,
},
},
};This starts 50 iterations per second. If k6 runs out of VUs, it reports dropped iterations, which means the test did not produce the intended load.
28. How do you handle authentication in a load test?
Get tokens in setup() or per VU in the first iteration, reuse them, and refresh before expiry. Use test accounts, and keep secrets in environment variables read with __ENV, not in the script.
29. How do you correlate dynamic values?
Extract values such as IDs or CSRF tokens from one response (with res.json() or HTML parsing) and pass them to the next request, as a real user flow would.
30. How do you run k6 in a CI pipeline?
Run a short smoke or average-load test on each merge to a test environment, with thresholds so the job fails on regressions. The exit code reflects threshold results. Grafana publishes GitHub Actions for setting up and running k6.
31. How do you make results comparable between runs?
Use the same environment size, data set and script version, record the build under test with tags, and store results in a time-series backend so trends are visible.
32. How do you avoid the load generator being the bottleneck?
Watch CPU and network on the machine running k6, avoid heavy work inside iterations, use discardResponseBodies when bodies are not needed, and spread load across several machines or use the k6 Operator or Grafana Cloud k6 when one machine is not enough.
33. What is the k6 Operator?
A Kubernetes operator from Grafana that runs distributed k6 tests as pods from a TestRun custom resource, splitting the load across many runners.
34. How do you set a threshold that stops the test early?
Use the object form with abortOnFail: true and an optional delayAbortEval, so a test that is clearly failing stops instead of hammering a broken system.
35. How do you pick the load numbers for a test?
Start from production data: peak requests per second, the mix of endpoints and user journeys, and growth plans. If no data exists, agree assumptions with the product team and write them down.
36. How do you test just one endpoint's performance under realistic background load?
Use two scenarios: one generating the general traffic mix and one focused on the endpoint, with tags so thresholds apply to the endpoint alone.
Senior: strategy (questions 37 to 41)
37. Where does load testing fit in a delivery pipeline?
Smoke tests on every change, short load tests on merges to main in a test environment, and longer stress and soak tests on a schedule or before big releases. Our post on shift-left performance testing covers the trade-offs.
38. How do you connect load test results to system metrics?
Send k6 metrics to the same Prometheus or Grafana stack that holds the service metrics and traces, then put both on one dashboard. Latency without CPU, database and queue data rarely explains a problem.
39. How do you define performance goals?
Write them as service level objectives with percentiles and error rates for named journeys, such as p95 checkout under 800 ms with under 1 percent errors at 200 requests per second. Turn each into a threshold.
40. Should you load test production?
Only with a plan: agreement from owners, off-peak timing, kill switches, monitoring and clear data handling. Many teams test a production-sized staging environment instead and run small synthetic checks in production.
41. How do you compare k6 with JMeter or Gatling?
k6 uses JavaScript scripts and a CLI-first workflow; JMeter has a GUI and a large plugin set; Gatling uses Scala, Java or Kotlin code. Pick the one the team will maintain and that fits the CI setup. The broader 65+ k6 interview questions page has more comparison questions.
Scenario questions (questions 42 to 46)
42. The test reports many dropped_iterations. What does it mean?
The arrival-rate executor needed more VUs than maxVUs allowed, usually because the system slowed down. The target load was not reached. Raise maxVUs if the load generator can handle it and report the slowdown itself as a finding.
43. p95 latency is fine but users still complain. What do you check?
p99 and maximum values, errors hidden by checks that do not fail the test, endpoints that the test does not cover, and front-end time that an HTTP test cannot see. A few browser VUs can show the front-end side.
44. Latency grows steadily during a four-hour soak test. What could cause it?
Memory leaks, growing queues, connection pool exhaustion, log or disk growth, or database tables and indexes growing with test data. Correlate with service metrics over the same period.
45. All requests fail with errors after a few seconds of a test. What first?
Check whether rate limiting, a WAF or bot protection in front of the system is blocking the load generator, and confirm the test environment can take the load. Coordinate with the team that owns those controls.
46. CI k6 runs are flaky: thresholds fail randomly. How do you stabilise them?
Use a dedicated, consistently sized test environment, warm it up before measuring, avoid shared environments that other tests use at the same time, and set thresholds with realistic margins. Engineer-level follow-ups are in k6 engineer interview questions.
Practice plan for beginners
Write a smoke test with one check and two thresholds, turn it into a ramping test with stages, then rewrite it as a constant-arrival-rate scenario and compare the results. Add it to a CI job. Related reading: which tests to automate first in CI and our Selenium interview questions for functional UI testing. The DevOps training in Pune covers test stages in pipelines, in Kharadi or live online.
Frequently asked questions
How many k6 questions are on this page?
46: 24 for freshers, 12 for 2 to 5 years, 5 senior questions and 5 scenarios.
Do I need to know JavaScript for k6?
Basic JavaScript is enough: imports, functions, objects and arrays. TypeScript is also supported.
What is the difference between a check and a threshold?
A check records pass or fail for an assertion. A threshold is a rule on a metric that fails the whole test and returns a non-zero exit code.
Who maintains k6?
Grafana Labs maintains k6 as an open source project, with Grafana Cloud k6 as the hosted option.
Can k6 test web pages in a browser?
Yes, with the k6/browser module, which drives Chromium. Browser VUs use far more resources than HTTP VUs.
Which executor should I use?
Use an arrival-rate executor when you want a fixed request rate, as with public traffic, and ramping-vus when you want to model a number of concurrent users.
Is it legal to load test any website?
No. Load test only systems you own or have written permission to test, such as the test.k6.io demo site.
Official references
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0