Scenario-Based k6 Interview Questions: Workloads (2027)

32 scenario-based k6 interview questions on workload modelling: executors, scenario mixes, arrival rates and per-scenario thresholds.

Sep 27, 2025 - 16:54
Nov 9, 2026 - 09:13
 0  62
Scenario-Based k6 Interview Questions: Workloads (2027)

Scenario-based k6 interview questions ask you to turn a traffic requirement into a test design: which executor, how many VUs, what arrival rate, how scenarios overlap and which thresholds fail the build. This guide works through those design problems with k6 2.x options checked against Grafana's documentation.

Reading results and debugging a finished run is covered in our keeper post, real-time k6 interview questions on test results. This page is about the step before that: modelling the workload. In k6 the word "scenario" is also a config object, so the questions below use both meanings.

Key takeaways

  • k6 has six executors: shared-iterations, per-vu-iterations, constant-vus, ramping-vus, constant-arrival-rate and ramping-arrival-rate.
  • Pick arrival-rate executors when the requirement is "requests per second"; pick VU executors when it is "concurrent users".
  • Every scenario accepts startTime (default "0s"), gracefulStop (default "30s"), exec, env and tags.
  • k6 tags each metric with the scenario name, so you can set thresholds per scenario.
  • For ramping-arrival-rate, preAllocatedVUs is required and maxVUs defaults to it.
  • The current line is k6 2.x; the GitHub releases page listed v2.3.0 as latest when this was checked.

Choosing an executor from the requirement

Requirement wordingExecutorMain options
"Run 1,000 checkout flows in total"shared-iterationsvus, iterations, maxDuration
"Each of 50 test accounts logs in exactly once"per-vu-iterationsvus, iterations (per VU)
"Hold 200 concurrent users for 30 minutes"constant-vusvus, duration
"Ramp users from 0 to 500 and back"ramping-vusstartVUs, stages
"Sustain 300 requests per second"constant-arrival-raterate, timeUnit, duration, preAllocatedVUs
"Grow from 100 to 1,000 RPS over 20 minutes"ramping-arrival-ratestartRate, stages, preAllocatedVUs, maxVUs

Freshers: reading the requirement

1. Product says "the API must handle 200 requests per second." Which executor do you use?

constant-arrival-rate with rate: 200 and timeUnit: '1s'. It starts iterations at a fixed rate regardless of how long each takes, so a slow server does not quietly lower the load. With a VU-based executor, slow responses would mean fewer requests per second.

2. What is the difference between "open" and "closed" models in one sentence each?

In a closed model (VU executors), a new iteration starts only when a VU finishes the last one, so throughput depends on response time. In an open model (arrival-rate executors), iterations start on a schedule, so throughput is set by you and response time shows up as latency and dropped iterations.

3. Fifty test accounts can each log in only once. How do you model that?

Use per-vu-iterations with vus: 50 and iterations: 1, and pick the account by exec.vu.idInTest from the k6/execution module. Each VU then runs exactly one login with its own account. The executor defaults are vus: 1, iterations: 1 and maxDuration: "10m".

4. When is shared-iterations the wrong choice?

When you need a steady load. Fast VUs take more of the shared iterations, so the load is uneven, and the test ends when the count is done rather than after a set time. It suits "process this many items" jobs, such as seeding data, more than steady-state tests.

5. How do you write a ramp-up, hold, ramp-down test for users?

export const options = {
  scenarios: {
    shoppers: {
      executor: 'ramping-vus',
      startVUs: 0,
      stages: [
        { duration: '5m', target: 300 },
        { duration: '20m', target: 300 },
        { duration: '5m', target: 0 },
      ],
      gracefulRampDown: '30s',
    },
  },
};

The middle stage holds the target, which is where you read steady-state latency.

6. What does gracefulStop do?

When a scenario's time is up, k6 waits up to gracefulStop (default 30s) for running iterations to finish before stopping them. Interrupted iterations are counted separately, so a long checkout flow does not look like a failure just because the clock ran out.

7. How do you run setup data creation before load starts?

Put it in setup(), which runs once before any scenario and passes its return value to every iteration. Keep it small, because setup() has a timeout (setupTimeout, 60 seconds by default). For large data, load a file with SharedArray instead.

8. What is a think time and when should you leave it out?

It is a sleep() that mimics a person reading the page. Keep it in VU-based user journeys so 300 VUs behave like 300 people. Leave it out of arrival-rate API tests, where the executor already controls pacing and extra sleep only forces k6 to allocate more VUs.

2 to 5 years: designing multi-scenario tests

9. Traffic is 70% browsing and 30% checkout. How do you model the mix?

Create two scenarios with separate functions and rates in the 70:30 ratio. This is clearer than a random branch inside one function, because each flow gets its own metrics and thresholds.

export const options = {
  scenarios: {
    browse: {
      executor: 'constant-arrival-rate',
      rate: 140, timeUnit: '1s', duration: '15m',
      preAllocatedVUs: 100, maxVUs: 300,
      exec: 'browse',
    },
    checkout: {
      executor: 'constant-arrival-rate',
      rate: 60, timeUnit: '1s', duration: '15m',
      preAllocatedVUs: 80, maxVUs: 250,
      exec: 'checkout',
    },
  },
};
export function browse() { /* GET catalogue pages */ }
export function checkout() { /* cart, pay, confirm */ }

10. How do you set a stricter latency target for checkout than browsing?

k6 adds a scenario tag to metrics, so you can threshold a submetric per scenario:

thresholds: {
  'http_req_duration{scenario:checkout}': ['p(95)<800'],
  'http_req_duration{scenario:browse}': ['p(95)<400'],
  'http_req_failed': ['rate<0.01'],
}

11. A batch job starts 10 minutes into peak traffic. How do you model it?

Add a third scenario with startTime: '10m'. Scenarios run in parallel, and startTime offsets one from the start of the test. This shows whether the batch job hurts user latency.

12. How do you pass different base URLs or flags to each scenario?

Use the per-scenario env object, read through __ENV in the function, or the tags object to label its metrics. Use -e on the command line for values shared by all scenarios, such as the target environment.

13. How do you size preAllocatedVUs for an arrival-rate test?

Estimate VUs as rate multiplied by iteration duration. At 200 iterations per second and 0.5 seconds per iteration you need about 100 VUs; add headroom and set maxVUs higher for slowdowns. If k6 runs out of VUs it records dropped_iterations instead of hitting the target.

14. The requirement is "find the breaking point." How do you design it?

Use ramping-arrival-rate with stages that keep climbing, plus thresholds with abortOnFail: true so the test stops once errors or latency cross the limit. The rate when the abort fired is your answer, backed by the timeline.

thresholds: {
  http_req_failed: [{ threshold: 'rate<0.05', abortOnFail: true, delayAbortEval: '1m' }],
},
scenarios: {
  stress: {
    executor: 'ramping-arrival-rate',
    startRate: 50, timeUnit: '1s',
    preAllocatedVUs: 200, maxVUs: 2000,
    stages: [
      { target: 200, duration: '5m' },
      { target: 600, duration: '10m' },
      { target: 1200, duration: '10m' },
    ],
  },
},

15. How do you design a soak test?

Run a realistic, moderate load (often around normal peak) for hours with constant-arrival-rate or constant-vus. You are looking for slow drift: memory growth, connection pool exhaustion or disk filling, so stream results to a time-series backend and compare the first hour with the last.

16. How do you model a flash sale spike?

Use ramping-arrival-rate with a very short ramp to a high target, a short hold and a drop. Watch recovery after the spike as much as the peak, because queues and autoscalers often misbehave on the way down.

17. A login flow and an API test must not share VUs. Is that guaranteed?

Yes. Each scenario gets its own VUs, so state such as cookies does not leak across them. Within a scenario, a VU keeps its cookie jar across iterations unless you reset it, which matters for login tests.

18. How do you run only one scenario from a file with many?

Use k6 run --env SCENARIO=checkout and build options.scenarios from that variable in the script. Keeping the selection logic in code means CI jobs and local runs use the same file.

19. How do you keep per-URL metrics manageable when URLs contain IDs?

Set a name tag on the request, for example tags: { name: 'GET /orders/:id' }, or use the http.url template literal. Otherwise each ID becomes its own time series and the results become hard to read and expensive to store.

20. Where should test data come from in a large multi-scenario test?

Load CSV or JSON once into a SharedArray so all VUs share one read-only copy in memory. Pick rows by VU or iteration ID to avoid collisions, such as two VUs buying the same limited item.

Senior: test strategy and pipelines

21. Which test types would you run in CI, and which on a schedule?

Run a short smoke test with tight thresholds on every merge to catch obvious regressions. Run average-load and stress tests nightly or before release in a production-like environment, and soak tests weekly. CI time and environment cost decide the split.

22. How do you turn an SLO into thresholds?

Translate each SLO into a metric and percentile: "99% of checkout requests under 1 second" becomes 'http_req_duration{scenario:checkout}': ['p(99)<1000']. Availability SLOs map to http_req_failed rates. Keep the threshold slightly tighter than the SLO so a test fails before users would notice.

23. The load generator cannot reach the target rate. How do you scale it?

First check generator CPU and memory. Reduce work per iteration, set discardResponseBodies: true when you do not read bodies, and lower log output. If one machine is still not enough, run distributed with the k6 Operator on Kubernetes or use Grafana Cloud k6.

24. How do you split one test across several k6 instances?

Use execution segments, which divide the scenarios between instances so they do not overlap. The k6 Operator sets these for you when you set parallelism on a TestRun resource.

25. A browser journey and API load must run together. How?

Create one scenario with the browser module for a few real browser sessions and another protocol-level scenario for the bulk of the load. Browser VUs are heavy, so keep their count small and let the API scenario create the pressure.

26. How do you compare two releases fairly?

Use the same script, data, executor settings, environment size and duration, and run each version more than once. Compare percentiles, not averages, and keep generator metrics to rule out client-side limits.

27. What would you tell a team that only runs ramping-vus tests?

That their throughput numbers hide server slowdowns, because slow responses lower the request rate. For capacity questions, add an arrival-rate test so the load stays fixed and degradation shows up as latency, errors and dropped iterations.

Scenario round: whiteboard designs

28. "Design a pre-release test for an e-commerce site."

Three scenarios: browse and search at the measured peak rate, checkout at its share of peak with stricter thresholds, and a back-office batch starting mid-test. Add a smoke run first, a 30-minute hold, and abort thresholds on error rate.

29. "A partner will send 5,000 webhook calls in one minute at midnight."

Use constant-arrival-rate at about 84 iterations per second for one minute, or shared-iterations with 5,000 iterations if the partner sends as fast as possible. Run both, since you do not control the partner's pacing.

30. "The test passed but production fell over at the same load." What do you suspect?

The model differed from reality: missing think time made fewer, faster users; cache hit rates were higher with repeated test data; or the test environment had different limits. Compare production access logs with the test's request mix and data spread.

31. "Model a mobile app that polls every 30 seconds while open."

Use constant-vus where each VU represents one open app, with sleep(30) between polls. Two thousand open apps then produce about 67 requests per second. A closed model fits here because the request rate really does depend on the number of connected clients.

32. "We moved to k6 2.x and an old script fails to start." What do you check?

Check the v2.0.0 release notes for removed features. For example, the externally controlled executor was removed, and k6 login was replaced by k6 cloud login. Our results-focused k6 guide lists more of these.

Practise before the interview

Take one public test site and write the same requirement three ways: closed, open and spike. Run each and compare http_reqs, dropped_iterations and p(95) latency. The k6 three-week prep plan sets a schedule, the k6 engineer questions cover fundamentals, and k6 load testing questions for beginners help if you are new. The broader 65+ k6 question bank is useful for revision.

Performance testing sits inside CI/CD work, which our DevOps training covers in Kharadi, Pune and live online.

FAQ

What is a scenario in k6?

It is a named entry under options.scenarios that sets an executor, timing and the function to run. Several scenarios can run in one test.

How many executors does k6 have?

Six: shared-iterations, per-vu-iterations, constant-vus, ramping-vus, constant-arrival-rate and ramping-arrival-rate.

Which executor should I use for a requests-per-second target?

Use constant-arrival-rate for a fixed rate or ramping-arrival-rate for a changing rate.

Can I set different thresholds per scenario?

Yes. Use the scenario tag in the metric name, for example http_req_duration{scenario:checkout}.

What is the default gracefulStop?

30 seconds. k6 waits that long for running iterations to finish when a scenario ends.

Why do I see dropped_iterations?

An arrival-rate executor had no free VU to start an iteration on time. Raise maxVUs or find why iterations are slow.

Is there an official k6 certification?

We could not confirm one on Grafana's site. Check Grafana's training pages for current options.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.