opyebAPI Bench

Capacity planning with Little's Law

Capacity · 7 min read

Most capacity plans start with a guess about servers and end with a load test that proves the guess wrong. There is a faster first step: Little's Law converts the two numbers you already publish in your SLO — request rate and latency — into the one number your runtime cares about, the concurrency needed to serve them without queueing.

What the law actually says

Little's Law states that for any stable system, the average number of items inside it equals the rate at which items arrive multiplied by the average time each item spends inside: L = λ × W. In an API, items are requests, the rate is requests per second, and the time is latency in seconds. The result is not a rough heuristic; it is an identity that holds whenever the system is stable, regardless of the distribution of arrivals or service times.

The practical consequence is blunt: if you promise 500 requests per second at 250 ms, you must be able to hold 125 requests in flight at that moment. Anything less and requests queue; anything much more and you are paying for idle capacity.

Why one number is never enough

A single average latency hides the shape of the distribution. Use all three percentiles, because each answers a different question. P50 sizes the steady state that most requests see. P95 is the concurrency you must absorb during normal peaks, and it is the number to size workers against. P99 is what your timeout must clear, otherwise the slowest requests are cut off exactly when the system is most loaded.

LatencyValueConcurrency at 500 rpsWhat it decides
P50120 ms60Typical in-flight load
P95250 ms125Worker and instance sizing
P99600 ms300Timeout and buffer limits

From concurrency to threads and instances

Concurrency is not a thread count by itself. If each worker handles one request at a time and holds a connection pool of ten per worker, one instance with sixteen workers can keep 160 requests in flight. Two instances give 320. At P95 you need 125, so utilisation is 39 percent — comfortable. At P99 the same fleet would be at 94 percent, which is where queueing starts to dominate.

Formula: concurrency L = rps × latency(s). Utilisation ρ = L ÷ (workers × pool × instances). Queue wait grows sharply as ρ approaches 1, which is why a 30 percent headroom target is common for p95-based sizing.

What the model deliberately leaves out

Little's Law tells you how much concurrency is required, not how a particular server behaves under it. Garbage collection pauses, database connection limits, lock contention and network retransmits all consume capacity without appearing in the formula. Treat the result as the floor for a design, then validate with a load test that ramps to 1.5 times your target rate.

Two habits keep the model honest. First, re-derive it whenever the P95 changes by more than a fifth, because a latency regression silently multiplies the concurrency you need. Second, record the estimate next to the measured result, so the gap between formula and reality becomes visible over time instead of being rediscovered in an incident.

A five-minute checklist

  • Write down the peak rate your SLO promises, not last month's average.
  • Measure P50, P95 and P99 under production-like load, not from a single machine.
  • Compute concurrency at all three, size workers at P95 and check the timeout against P99.
  • Add the failure rate and retry count, because retries are extra arrivals.
  • Keep 25 to 40 percent headroom and verify with a load test.

Where teams get the input wrong

The most common error is plugging in the average request rate over a month instead of the peak the SLO covers. A service that averages 120 requests per second can easily see 500 at the evening peak, and the fleet sized for 120 will queue long before the peak arrives. Take the peak from your own traffic history and add the planned growth for the next two quarters.

The second error is measuring latency on an idle system. Latency under no load is optimistic: caches are warm, queues are empty and the database has nothing else to do. Measure under production-like concurrency, or at least under a load test that reaches your target rate, otherwise the concurrency you derive will be too small by exactly the amount that matters.

  • Use the 95th-percentile minute of traffic, not the monthly average.
  • Measure latency while the system is loaded, not while it is idle.
  • Re-derive the number after any change to instance type, pool size or dependency.

One useful sanity check: divide the concurrency you compute by the number of worker slots you actually run. If the answer is above 0.75 at P95, you are one latency regression away from an incident, regardless of what the CPU graph says.

Open the calculators and put these numbers to work on your own API.

Open API Bench

Frequently asked questions

Does Little's Law assume a particular arrival pattern?

No. It holds for any stable system, whatever the arrival or service distribution, as long as the system is not diverging. What it does not tell you is the waiting time distribution, which is why the queue estimate needs an additional model such as Erlang C.

Should I size on P95 or P99?

Size worker slots and instances on P95, then confirm that the timeout comfortably exceeds P99. Sizing on P99 usually doubles the fleet for an event that lasts seconds; sizing only on P50 guarantees queueing at every peak.

Why does utilisation above 80 percent cause trouble?

Queue length grows non-linearly as utilisation approaches one. At 80 percent the wait is already several times the service time in a single-queue system, and any burst pushes it higher. Headroom is cheaper than an incident.

Sources

Related guides