K6 Engineer Interview Questions with Answers (2027)
55 k6 engineer interview questions with answers: scripting, checks vs thresholds, executors, arrival rate, Prometheus output, CI and k6 Operator.
K6 engineer interview questions check whether you can write Grafana k6 test scripts in JavaScript or TypeScript, model realistic load with scenarios and executors, set pass or fail thresholds, read results such as p(95) latency and error rate, and run tests in CI/CD or on Kubernetes. Expect both scripting questions and scenarios about slow or failing systems.
This page has 55 numbered questions grouped by level, followed by production scenarios. APIs and options were checked against the Grafana k6 documentation in November 2026 and reflect k6 v1 and later. For why load tests belong early in the pipeline, read our post on shift-left performance testing.
Key takeaways
- k6 scripts are JavaScript modules with an init context, an optional
setup()andteardown(), and a default (or named) function that each virtual user runs in a loop. - Since k6 v1.0, you can run TypeScript files directly with
k6 run script.ts, andk6/browser,k6/net/grpcandk6/cryptoare stable modules. - Checks record whether responses look right but do not fail a test. Thresholds decide pass or fail and set a non-zero exit code, which is what CI needs.
- Scenarios and executors control load shape. Know the difference between closed models (VU-based) and open models (arrival rate).
- Results can stream to Prometheus remote write, InfluxDB, JSON, CSV or Grafana Cloud k6 and are usually viewed in Grafana dashboards.
- On Kubernetes, the k6 Operator runs distributed tests from a
TestRuncustom resource.
How to use this guide
Each answer starts with the reply you can give in an interview, then adds the detail an interviewer may probe next. Other k6 pages on this blog have a different focus: 65+ k6 interview questions is a shorter general set, and k6 load and performance testing questions focuses on test types. This page is the engineer-level set with scripting, CI and scenario work. For broader DevOps rounds, see the 200+ DevOps interview questions guide.
| Your experience | Read first | Practise |
|---|---|---|
| Fresher or manual tester moving to performance | Questions 1 to 16 | Write a script with a check and a threshold against a test API you own |
| 2 to 5 years | Questions 17 to 34 | Model the same load with a VU executor and an arrival-rate executor and compare results |
| Senior or performance lead | Questions 35 to 45 | Run k6 in CI with Prometheus remote write and a Grafana dashboard |
| Everyone | Scenarios 46 to 55 | Explain symptom, cause, fix and prevention aloud |
Questions for freshers
1. What is k6?
k6 is an open source load testing tool from Grafana Labs. You write tests in JavaScript or TypeScript, and a Go engine runs them, so a single machine can simulate many virtual users with modest CPU and memory. It tests HTTP APIs, WebSockets, gRPC and browsers (through k6/browser), and it is built to run from the command line and CI.
2. What does the smallest useful k6 script look like?
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<500'],
},
};
export default function () {
const res = http.get('https://test.example.com/api/health');
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1);
}
Run it with k6 run script.js. Ten virtual users loop over the default function for 30 seconds, and the test fails if more than 1% of requests fail or p95 latency exceeds 500 ms.
3. What is a virtual user (VU)?
A VU is an independent JavaScript runtime that runs your default function in a loop. Each loop is one iteration. VUs do not share memory, so a variable set in one VU is not visible to another. The number of VUs limits how many iterations can run at the same time.
4. What are the stages of a k6 test lifecycle?
The init context runs once per VU and loads modules, files and options. setup() runs once before load starts and can return data. The default function (the VU code) runs repeatedly for each VU. teardown() runs once at the end and receives the setup data. HTTP requests are not allowed in the init context.
5. What is the difference between a check and a threshold?
A check is an assertion on one response, such as "status is 200". Failed checks are counted in the checks rate metric, but they do not fail the test. A threshold is a pass or fail rule on a metric for the whole test, such as p(95)<500. If any threshold fails, k6 exits with a non-zero code. To fail on bad checks, add a threshold on the checks metric, for example checks: ['rate>0.99'].
6. Which built-in HTTP metrics do you look at first?
http_req_duration (total request time excluding connection setup reuse), http_req_failed (rate of failed requests), http_reqs (request count and rate) and iterations. When latency is high, break http_req_duration into http_req_waiting (time to first byte), http_req_connecting and http_req_tls_handshaking to see where time goes.
7. Why do scripts call sleep()?
Real users pause between actions. Without sleep(), each VU fires requests as fast as possible, which tells you about raw throughput but not about realistic concurrent users. Use randomized think time where it matters. In arrival-rate executors, sleep affects how many VUs you need rather than the request rate.
8. What are the common types of performance tests?
Smoke (minimal load to check the script and system work), average-load, stress (above normal load), spike (sudden jump), soak (normal load for hours) and breakpoint (increase until the system fails). k6 runs all of them; only the load shape in options changes.
9. How do you pass configuration such as a base URL into a script?
Use environment variables through the __ENV object: k6 run -e BASE_URL=https://staging.example.com script.js, then read __ENV.BASE_URL in the script. This keeps one script for several environments.
10. How do you load test data such as a list of users?
Read the file in the init context with open() and wrap it in a SharedArray from k6/data. The data is parsed once and shared read-only across VUs, which saves memory compared with every VU holding its own copy.
import { SharedArray } from 'k6/data';
const users = new SharedArray('users', () => JSON.parse(open('./users.json')));
11. How do you group requests that belong to one user action?
Wrap them in group('checkout', () => { ... }). k6 reports a group_duration metric and tags requests with the group name, so you can see the time for a whole flow and filter results by group.
12. What are tags used for?
Tags are labels on metrics. k6 adds system tags such as status, method and url, and you can add your own per request or for the whole test. Thresholds can target tagged subsets, for example 'http_req_duration{name:login}': ['p(95)<800'].
13. A URL contains IDs, and the results show thousands of separate URLs. How do you fix it?
Set the name tag to a fixed value, or use the http.url template literal so k6 groups requests under one name. Otherwise each ID creates a new time series, which makes reports hard to read and can overload metric backends.
14. How do you handle authentication in a test?
Log in once in setup() if all VUs can share a token, return it, and use it in the default function. If each user needs its own session, log in per VU (for example on the first iteration) using credentials from a SharedArray. Keep secrets in environment variables or the CI secret store, never in the script.
15. What does k6 print at the end of a run?
An end-of-test summary with each metric's aggregates (avg, min, med, max, p(90), p(95)), check pass rates and threshold results marked as passed or failed. You can replace or extend it with a handleSummary() function that writes JSON, HTML or other formats.
16. Can k6 test a web page in a real browser?
Yes, with the k6/browser module, which drives Chromium and reports browser metrics such as Web Vitals. Browser tests use far more resources per VU, so a common pattern runs most load as protocol-level HTTP and a few browser VUs alongside to measure the front end.
Questions for 2 to 5 years of experience
17. What are scenarios and executors?
A scenario is a named workload in options.scenarios. Each scenario uses an executor that decides how VUs and iterations are scheduled. Several scenarios can run in one test, at the same time or one after another using startTime, and each can call a different exported function with exec.
18. Name the k6 executors and when you would use each.
| Executor | Model | Use it when |
|---|---|---|
| shared-iterations | Closed | A fixed total number of iterations shared by VUs |
| per-vu-iterations | Closed | Each VU must run an exact number of iterations |
| constant-vus | Closed | A fixed number of concurrent users for a duration |
| ramping-vus | Closed | Concurrent users go up and down in stages |
| constant-arrival-rate | Open | A fixed number of iterations per time unit, regardless of response time |
| ramping-arrival-rate | Open | The iteration rate changes in stages |
| externally-controlled | Closed | VUs are changed at run time through the REST API or CLI |
19. What is the difference between open and closed load models, and why does it matter?
In a closed model, a VU starts its next iteration only after the previous one finishes. If the system slows down, the request rate drops, which hides the problem (coordinated omission). In an open model (arrival-rate executors), new iterations start at the configured rate whether or not earlier ones finished, which matches traffic from many independent users. Use open models when you want to know how the system behaves at a target request rate.
20. Show an arrival-rate scenario for 200 requests per second.
export const options = {
scenarios: {
api_load: {
executor: 'constant-arrival-rate',
rate: 200,
timeUnit: '1s',
duration: '10m',
preAllocatedVUs: 100,
maxVUs: 400,
},
},
};
If k6 runs out of VUs to start iterations on time, it skips them and counts them in the dropped_iterations metric.
21. What does dropped_iterations tell you?
That k6 could not start iterations on schedule, usually because all VUs were busy and maxVUs was reached. Either the system under test is slowing down (iterations take longer) or you allocated too few VUs. Add a threshold on it so the test fails instead of reporting a lower load than you intended.
22. How do you stop a test early when the system is clearly failing?
Use the object form of a threshold with abortOnFail: true and optionally delayAbortEval so it waits before evaluating.
thresholds: {
http_req_failed: [{ threshold: 'rate<0.05', abortOnFail: true, delayAbortEval: '1m' }],
},
23. How do you create a custom metric?
Import Counter, Gauge, Rate or Trend from k6/metrics, create it in the init context and add values in VU code. For example, a Trend for the time an order takes to appear in a list after it is created. Thresholds can use custom metrics like built-in ones.
24. How do you get information about the current VU, iteration or scenario?
Import exec from k6/execution. It exposes values such as exec.vu.idInTest, exec.scenario.name and exec.scenario.iterationInTest, which help you pick unique test data per iteration. exec.test.abort() stops the whole test from code.
25. How do you correlate dynamic values, such as a CSRF token, between requests?
Extract the value from the previous response and send it on the next request. Use res.json() for JSON bodies, or parseHTML from k6/html for HTML forms. k6 also keeps cookies per VU automatically through its cookie jar.
26. How do you send requests in parallel within one iteration?
Use http.batch() with an array of requests. It sends them in parallel, like a browser loading several assets, and returns an array of responses. The batch and batchPerHost options limit how many run at once.
27. How do you reduce memory use on the load generator?
Set discardResponseBodies: true in options and enable bodies only on requests you need to read with responseType: 'text'. Use SharedArray for data, avoid building large objects per iteration and keep URL tag cardinality low. Monitor the generator's CPU and memory, because a saturated generator reports false latency.
28. How do you send k6 results to Prometheus?
Use the Prometheus remote write output: set K6_PROMETHEUS_RW_SERVER_URL and run k6 run -o experimental-prometheus-rw script.js. The Prometheus server must have its remote write receiver enabled. Grafana provides dashboards for k6 metrics. Our Prometheus and Grafana guide explains the monitoring side.
29. Which other outputs can k6 write to?
JSON and CSV files, InfluxDB, Prometheus remote write, OpenTelemetry, StatsD-style backends through extensions, and Grafana Cloud k6. Use --out (or -o) and repeat it to send results to several outputs at once.
30. How do you run k6 in a CI pipeline?
Install k6 or use the grafana/k6 container image, run a short smoke or load test against a deployed test environment, and let thresholds set the exit code so the job fails on a regression. Save the summary as an artifact. A GitHub Actions example:
jobs:
load-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: grafana/setup-k6-action@v1
- uses: grafana/run-k6-action@v1
with:
path: tests/smoke.js
Our guide to CI/CD quality gates shows where a performance gate fits among other checks.
31. Can you write k6 tests in TypeScript?
Yes. Since v1.0, k6 run script.ts runs TypeScript directly without a separate build step. Install the @types/k6 package for editor autocompletion.
32. How do k6 extensions work?
Extensions add Go-based modules or outputs, for example for Kafka or SQL databases. Traditionally you build a custom k6 binary with xk6. k6 v1 also introduced automatic extension provisioning, where k6 resolves supported extensions you import; check the current docs for which commands and flags support it.
33. How do you test a gRPC service?
Use k6/net/grpc: create a Client, load the .proto files in the init context (or use server reflection), connect in the VU code and call methods with client.invoke(). Check the response status against grpc.StatusOK.
34. How do you make a load test realistic?
Base the mix of requests and the arrival rate on production data (access logs or APM traffic), use varied test data so caches behave as in production, add think time, run against an environment sized like production, and include background jobs that run at the same time in real life.
Questions for senior engineers
35. How do you run a large distributed test on Kubernetes?
Install the k6 Operator and create a TestRun resource that references your script in a ConfigMap and sets parallelism. The operator starts that many runner pods and splits the load among them using execution segments.
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: checkout-load
spec:
parallelism: 4
script:
configMap:
name: checkout-test
file: test.js
Send results to a central output such as Prometheus, because each pod's own summary covers only its share.
36. How do you choose SLO-based thresholds instead of guessing numbers?
Take the service's agreed SLOs (for example 99% of checkout requests under 800 ms) and turn them into thresholds on tagged metrics. Where no SLO exists, record a baseline from production and from a known good build, then set thresholds slightly looser than the baseline so you catch regressions without flaky failures.
37. How do you tell whether the bottleneck is the system under test or the load generator?
Watch CPU, memory and network on the generator. If the generator is near saturation, latency numbers are unreliable. Compare http_req_waiting (server time) with total duration, and check server-side metrics and traces at the same timestamps. Split load across more generators if needed.
38. How do you correlate k6 results with application traces?
Send a trace header on each request so backend traces link to k6 requests. The k6/experimental/tracing module and Grafana Cloud k6 integrations add trace context headers. Then view slow requests in Grafana Tempo or another tracing backend alongside k6 metrics.
39. What is the risk of running load tests against production, and how do you reduce it?
You can cause the outage you are trying to prevent, pollute analytics and trigger real side effects such as emails or payments. If you must, run off-peak, start small with abort thresholds, mark test traffic with a header so it can be filtered, use test accounts and stub payment calls, and agree a stop procedure with the on-call team.
40. How would you build a performance testing practice for several teams?
Provide a shared library of k6 helpers (auth, data, tagging), a standard CI template with a smoke test on every merge and a larger scheduled load test, a central Grafana dashboard, and threshold conventions tied to SLOs. Review results in release meetings and track trends over time rather than single runs.
41. How do you test a message-driven or asynchronous system with k6?
Measure end-to-end time, not just the API call. Send the request, then poll a status endpoint or read from the queue through an extension, and record the elapsed time in a custom Trend. Watch queue depth and consumer lag on the server side during the test.
42. How do you compare two builds fairly?
Use the same script, data, environment size and load shape, run each more than once, and compare percentiles and error rates rather than averages. Store results in a time series backend with a build tag so the comparison is a query, not two screenshots.
43. When is k6 not the right tool?
When the team needs a record-and-replay GUI and will not write code, when the protocol is not supported by k6 or an extension, or when you need deep front-end profiling, where browser developer tools and real user monitoring fit better. Say this plainly in interviews; it shows judgement.
44. How do you keep secrets out of k6 scripts and logs?
Pass them through environment variables from the CI secret store or Kubernetes Secrets mounted into runner pods. Avoid console.log of request bodies or headers that contain tokens, and avoid putting tokens in URLs, because URLs become tags in result backends.
45. What do you report after a load test?
The goal and load model, environment and build version, results against thresholds (p95, p99, error rate, throughput), the bottleneck found with evidence from server metrics or traces, and recommended actions with owners. Keep the raw results linked so others can check them.
Production scenarios
46. Scenario: p95 latency is fine at 100 VUs but jumps at 150 VUs.
Something saturates between those loads. Check server CPU, database connection pool usage, thread pools and rate limiters at the moment latency rises. A connection pool at its maximum is a common cause. Rerun with a ramping-arrival-rate executor to find the exact rate where it breaks, then fix the limit and retest.
47. Scenario: the test passes locally but fails in CI with timeouts.
The CI runner is probably smaller or far from the target. Compare generator CPU, network path and target environment. Run CI tests from a runner close to the environment, lower the load to what the runner can produce, and reserve larger tests for dedicated generators or the k6 Operator.
48. Scenario: http_req_failed is high, but the server logs show no errors.
Requests may be failing before reaching the application: DNS errors, TLS handshake failures, a load balancer or WAF returning 429 or 503, or the generator running out of ports or file descriptors. Read the error and error_code fields on failed responses and check proxy and load balancer logs.
49. Scenario: a soak test shows latency rising slowly over four hours.
That pattern suggests a resource leak: memory growth, connections not returned to a pool, an unbounded cache or growing tables without an index. Watch application memory and GC metrics alongside latency. Restarting the service and seeing latency drop confirms it is state inside the process.
50. Scenario: results show far fewer requests per second than the target, with no threshold failures.
With a VU-based executor, slow responses reduced the rate (closed model). With an arrival-rate executor, check dropped_iterations. Switch to an arrival-rate executor, raise maxVUs, and add a threshold on dropped_iterations so the test fails when it cannot generate the planned load.
51. Scenario: the API sits behind a rate limiter, and the test hits 429 responses.
Decide what you are testing. To test the service, run against an environment with the limit raised or with an allow-listed test client. To test the limiter, assert that 429 responses appear at the expected rate and that the service stays healthy. Do not treat expected 429s as failures; use http.setResponseCallback to mark them as expected.
52. Scenario: a release passed the CI load test but slowed down in production.
The test did not match production. Compare the request mix, data size, cache hit rates and environment size. Add the slow endpoint and realistic data to the test, and add post-deployment checks. Our list of post-deployment validation steps covers what to watch after release.
53. Scenario: different k6 runner pods in a distributed test report very different latencies.
Check node placement and resource limits on the runner pods. Pods on busy nodes or with low CPU limits add client-side delay. Give runners dedicated nodes or guaranteed resources, and compare server-side latency, which should not depend on which runner sent the request.
54. Scenario: a spike test makes the autoscaler add pods, but errors appear before they are ready.
New pods take time to start, and traffic arrives faster. Options include keeping more minimum replicas, faster startup and readiness, autoscaling on a leading metric such as request rate, and a queue or rate limit to absorb short spikes. Rerun the spike test to confirm the change.
55. Scenario: product asks, "How many users can we handle?"
Turn it into a measurable question: which user journeys, at what latency and error targets. Run a breakpoint test with a ramping-arrival-rate executor on those journeys, find the rate where thresholds fail, then translate rate into users using think time and session length from production analytics. Report the answer with its assumptions.
Training
k6 results are only as useful as the dashboards and alerts around them. The Prometheus and Grafana training covers metrics, PromQL and dashboards, and the DevOps training covers the CI/CD pipelines where k6 gates run. Classes run in Kharadi, Pune, and live online across India.
FAQ
What do k6 engineer interviews usually cover?
Script structure, checks versus thresholds, scenarios and executors, open versus closed load models, metrics such as p(95) and http_req_failed, running k6 in CI and on Kubernetes, and troubleshooting scenarios where the system or the test is at fault.
What is the difference between checks and thresholds in k6?
Checks assert on individual responses and are counted but do not fail a test. Thresholds are pass or fail rules on metrics for the whole run and make k6 exit with a non-zero code when they fail.
Can k6 run TypeScript?
Yes. From k6 v1.0, k6 runs .ts files directly with k6 run, without a separate transpile step.
Which executor should I use to simulate a fixed request rate?
Use constant-arrival-rate, or ramping-arrival-rate if the rate changes over time. They start iterations at the configured rate regardless of response time, and report dropped_iterations when they cannot keep up.
How do I view k6 results in Grafana?
Stream results to Prometheus with the experimental-prometheus-rw output, or to InfluxDB, and import a k6 dashboard in Grafana. Grafana Cloud k6 also stores and charts results.
Is there an official k6 certification?
We could not find a k6 certification listed on Grafana Labs' official pages, so interviewers judge you on scripts and answers. Check grafana.com for current learning paths.
How do I run k6 on Kubernetes?
Install the k6 Operator and create a TestRun resource with your script and a parallelism value. The operator starts runner pods and splits the load between them.
Official references
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0