Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท Scenarios and Executors

Arrival-Rate Executors

Model an open workload in k6 with constant-arrival-rate and ramping-arrival-rate, size preAllocatedVUs and maxVUs correctly, and understand dropped iterations.

A public API does not receive "50 users who each wait for the previous answer". It receives requests at some rate (50 per second, say), and new ones keep arriving even when earlier ones are still stuck. The arrival-rate executors model exactly that, the open workload model. You say how many iterations should start per time unit, and k6 starts them on schedule using as many VUs as it takes. If the server slows down, k6 does not slow down with it. That honesty is why arrival-rate executors are the preferred tool for capacity tests, spike tests and breakpoint tests.

constant-arrival-rate

JavaScript
export const options = {
  scenarios: {
    api_traffic: {
      executor: 'constant-arrival-rate',
      rate: 50,              // iterations...
      timeUnit: '1s',        // ...per second
      duration: '5m',
      preAllocatedVUs: 20,   // VUs created before the test starts
      maxVUs: 100,           // upper limit k6 may grow to
    },
  },
};

k6 starts 50 iterations every second for five minutes, 15,000 in total. rate and timeUnit can express slower patterns too: rate: 30, timeUnit: '1m' is one iteration every two seconds.

ramping-arrival-rate

The rate follows stages, like ramping-vus, but the targets are rates:

JavaScript
scenarios: {
  breakpoint: {
    executor: 'ramping-arrival-rate',
    startRate: 10,
    timeUnit: '1s',
    preAllocatedVUs: 50,
    maxVUs: 500,
    stages: [
      { duration: '2m', target: 50 },
      { duration: '2m', target: 100 },
      { duration: '2m', target: 200 },
      { duration: '2m', target: 400 },
    ],
  },
},

Each stage moves the rate linearly toward its target. Add a threshold with abortOnFail (Thresholds) and this becomes a breakpoint test that stops itself when the error rate climbs.

How many VUs are needed?

An iteration needs a free VU to run. The number of VUs required follows Little's law: VUs = rate x iteration duration. At 50 iterations per second with each iteration taking 400 ms, you need about 20 VUs. If the server slows to 2 seconds per iteration, you need 100.

  • preAllocatedVUs are created and initialised before the scenario starts. Allocating VUs mid-test is expensive and can distort timings, so make this at least the VUs you expect to need.
  • maxVUs is the ceiling. If the preallocated ones are all busy, k6 creates more, up to maxVUs. Set it comfortably above the expectation, but remember each VU costs memory.

Dropped iterations

What if even maxVUs is not enough? k6 cannot start the iteration on time, so it drops it and counts it in the dropped_iterations metric. The summary then shows something like dropped_iterations: 1200. Dropped iterations are a warning with two possible meanings:

  1. Your load generator is too small (not enough VUs), so the test did not reach the target rate. Fix the numbers or the machine.
  2. The system under test became so slow that iterations stack up. That is a finding.

You can add a threshold such as dropped_iterations: ['count==0'] to make this explicit.

flowchart LR
  T["Timer: 50 iterations/s"] --> F{"Free VU<br/>available?"}
  F -->|"yes"| R["Run iteration"]
  F -->|"no, below maxVUs"| N["Allocate a new VU<br/>(then run)"]
  F -->|"no, at maxVUs"| D["dropped_iterations +1"]

Open versus closed in one table

VU-based (closed) Arrival-rate (open)
You set number of users iterations per time unit
Slow server means fewer requests more concurrent VUs, possible drops
Best for internal tools, session models public APIs, capacity limits
Think time essential usually unnecessary

With arrival-rate executors you normally do not add sleep for pacing: the executor already controls how often iterations start. A sleep only makes each iteration hold its VU longer and raises the VU count you need.

A stand-in that drops iterations

The program below is not k6. It starts one iteration every 10 ms (100 per second) against a server that takes 50 ms per call, using at most 3 workers, so 5 would be needed (rate x duration = 100 x 0.05). Iterations that find no free worker are dropped, just as k6 reports dropped_iterations. Counts depend on timing, so it prints only comparisons that are always true.

Node.js Stand-in: arrival rate, VU limits and dropped iterations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The same arrival schedule produced drops when the VU pool was too small and none when it was large enough; the peak concurrency of the large pool shows how many VUs Little's law predicts you really need.

Choosing rate, timeUnit and VUs

  1. Start from the traffic you expect: for example 200 requests per minute during the peak hour. If each iteration makes 4 requests, the iteration rate is 50 per minute.
  2. Estimate the iteration duration from a smoke test, then compute rate x duration for preAllocatedVUs.
  3. Set maxVUs to about twice that.
  4. Watch dropped_iterations and the vus metric during the first runs and adjust.

Common mistakes

  • Setting maxVUs too low and quietly measuring a lower rate than intended.
  • Adding sleep() to model think time and then wondering why more VUs are needed.
  • Forgetting that rate counts iterations, not requests.
  • Using a tiny preAllocatedVUs so that VU creation during the test disturbs the measurements.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does constant-arrival-rate with rate: 30 and timeUnit: '1m' do?

    rate is the number of iterations started per timeUnit, so 30 per minute means one every two seconds.
  2. 2. What is dropped_iterations?

    When maxVUs is exhausted, k6 cannot start the iteration on schedule and counts it as dropped.
  3. 3. Roughly how many VUs does 50 iterations/s need if each iteration takes 400 ms?

    VUs = rate x duration = 50 x 0.4 = 20 (Little's law).
  4. 4. Why use arrival-rate executors for a public API test?

    The open model does not self-throttle like VU-based tests, so it shows how the system behaves when saturated.

Summary

  • constant-arrival-rate and ramping-arrival-rate start iterations at a rate per timeUnit.
  • They need preAllocatedVUs and maxVUs; estimate with VUs = rate x iteration duration.
  • When no VU is free, iterations are dropped and counted in dropped_iterations.
  • They model open workloads (public traffic), expose overload honestly, and rarely need sleep.
  • Pair ramping-arrival-rate with abortOnFail thresholds for breakpoint tests.

Next: Multiple Scenarios and exec