Course contents

15. Performance Engineering Lesson 3 of 8

Little's Law

Relate requests in the system, throughput and time in the system with L = λ × W, size pools with it, and learn when its assumptions fail.

14 minAdvanced7 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • L = λ × W: the average number of requests in a system equals their throughput times the average time each spends in it.
  • It needs no assumption about arrival patterns, service-time distributions or queueing discipline, only a stable system and long-run averages.
  • Use the effective throughput (what completes) with the latency of those requests, not the offered rate.
  • L, λ and W must describe the same boundary: the whole user-visible path, the server’s workers or just the queue are different, equally valid equations.
  • When arrivals exceed capacity and the queue is unbounded there is no steady state: L and W grow without limit and any single reading is an artefact.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Little's law relates three averages of any system with a boundary around it:

  • λ (lambda): the rate at which requests pass through the boundary, in requests per second (the throughput).
  • W: the average time a request spends inside, from entering to leaving, in seconds.
  • L: the average number of requests inside at any moment.

For a stable system: L = λ × W. A service that completes 400 requests per second, each spending 250 ms inside, holds 400 × 0.25 = 100 requests on average. Written the other way, W = L ÷ λ and λ = L ÷ W.

John Little proved it in 1961. It is an accounting identity about long-run averages, which is why it needs no assumption about how requests arrive, how long they take, or in what order they are served.

Why it exists

Engineers constantly need one of the three numbers and have the other two: how many connections a database needs (L) given the query rate and the time a connection is held; how long requests take (W) given how many are in flight and the throughput; what rate a system is really sustaining (λ) given its concurrency and latency. The law turns monitoring data you already have into the number you lack, and it is a sanity check: if the three numbers you measure do not agree, one of them was measured on a different boundary, or the system is not stable.

How it works

A worked example. An API receives 120 requests per second and each request spends about 51 ms between the user sending it and the answer coming back (5 ms there, 40 ms of work, 5 ms back, almost no waiting). L = 120 × 0.051 ≈ 6 requests are in the system on average. In the lesson's simulation the average number in the system is measured by sampling every 100 ms and matches that product.

Sizing concurrency. The requests that are in service need a worker, thread or connection each. With 120 requests per second and 40 ms of service, 120 × 0.040 = 4.8 workers are busy on average, so you need more than 4.8: the server in the lesson has 8, which is 60% busy. The Server Capacity calculator in this lab shows the same figure as "requests in progress" (CPU time only). Averages are a floor, not a size: bursts and variation put the instantaneous number well above the average.

L grows faster than traffic. At 180 requests per second (+50%) the server is about 90% busy and requests begin to queue, so W rises as well and L roughly doubles. The law is always true; it just says L follows both factors. This is why pools that were comfortable at moderate load run out as traffic approaches capacity.

Choose the boundary first. The law holds for any boundary, but L, λ and W must describe the same one:

  • The user's view (send to answer): W = 51 ms, L ≈ 6.
  • The server's workers only: each request occupies a worker for the 40 ms of service, L = 120 × 0.040 = 4.8 busy workers.
  • The waiting line only: Wq is a millisecond or two, so Lq ≈ 0.1.

Mixing them produces wrong answers: multiplying λ by the user's W and calling it busy workers overstates them, and a gauge that counts requests from the moment a load balancer accepts them will not match an application timer that starts later.

Effective throughput. λ is the rate of the flow whose time-in-system is W. If a server can finish 200 requests per second, is offered 260 and rejects the rest at its door, the served requests spend about 140 ms in the system (they wait behind a full queue): L = 200 × 0.14 ≈ 28. Using the offered 260 gives about 35, which is 25–30% too high, because the rejected requests were never inside for 140 ms. Latency percentiles and averages in this lab count successful requests only; the error rate is shown beside them for exactly this reason.

Stability. The identity holds for averages over a long enough period in a system whose averages exist: arrivals roughly equal departures, and the amount inside does not grow without bound. It also assumes that, over the period you measure, requests that started before it began and are still inside at its end are a small part of the total. If arrivals exceed capacity and the queue is unbounded (260 per second offered, 200 per second served, nothing rejected) none of that is true: the backlog grows by about 60 requests per second, every request waits longer than the one before it, and L and W grow without limit. Throughput stays at 200 per second, W is large and rising, and L stays about 30% above λ × W because requests still waiting are counted in L but are not yet in the completed requests' W. The law is not wrong; it just does not predict a settled value, and every reading depends on when you took it.

When to use it

  • Sizing thread pools, connection pools, worker counts and in-flight limits from rate and time (with headroom for bursts).
  • Cross-checking monitoring: in-flight gauge, request rate and latency should agree on one boundary.
  • Estimating throughput from concurrency and latency when you can measure those directly (for example a load test with a fixed number of virtual users).
  • Reasoning about how much memory or how many sockets a service needs per unit of traffic.

When not to

  • As a prediction of latency or tail latency: it relates averages and says nothing about the distribution; use queueing formulas and load tests for that.
  • On a system that is visibly not stable: growing queues, an ongoing ramp or a recent failure. Measure a stable stretch or reason about the transient explicitly.
  • With figures taken from different boundaries or different populations (all requests for L, successful requests only for W) without saying so.

Trade-offs

You choose You gain You must watch
The user's view as the boundary What users experience, including network and queueing Network and client time you do not control
Only the server's workers Exactly the concurrency to provision It hides queueing delay before the worker
Effective throughput for λ A correct L for the flow that completes Rejected and timed-out traffic needs its own accounting
Successful requests for W A latency that describes finished work Survivor bias: failing the slow requests lowers W

Alternatives

  • Utilisation law and other operational laws (U = X × S, the forced-flow law): similar identities that also need only measured averages.
  • Queueing models (M/M/1, M/G/1, M/M/c): predict W from λ and S, including how it explodes near full utilisation (see Queueing Fundamentals).
  • Load testing: measure the real relationship between concurrency, throughput and latency for your system.

Failure modes

  • Offered rate as λ: sizing from the rate clients send rather than the rate the system completes overstates L whenever anything is rejected or times out.
  • Mixed boundaries: an in-flight gauge from one tier compared with latency from another, then blaming the law when the numbers disagree.
  • Averages as pool sizes: a pool of exactly L connections queues constantly, because arrivals are bursty and service times vary.
  • Reading a transient as a steady state: taking one window during a ramp or an overload and treating the numbers as a baseline.
  • Survivor bias: a short timeout turns the slowest requests into errors, so the average latency of successes falls while reliability falls with it.

In production

Use the law to turn a latency SLO and a target rate into a concurrency budget (connections, threads, in-flight limits), then add headroom for bursts and for losing an instance. Name the boundary in dashboards ("in flight at the load balancer", "busy workers", "queued"), and chart arrival rate, completion rate and in-flight together: a widening gap between arrivals and completions is the first sign that a system has stopped being stable. Alert on the error rate next to latency, never on latency alone.

Common misconceptions

  • "Little's law needs Poisson arrivals or exponential service times." It needs neither.
  • "Doubling the traffic doubles the concurrency." Only if W stays constant; near saturation W grows too, and L grows faster than λ.
  • "L is the number of busy workers." Only if the boundary is the workers; the user's view includes network time and waiting.
  • "If the numbers do not satisfy the law, the law is wrong." Check the boundary, the throughput definition (effective vs offered), the latency population and stability first.

Interview angle

State the formula, then name the boundary: "at 5,000 requests per second with 200 ms per request, about 1,000 requests are in flight; if each holds a connection for the whole time, that is the floor for the pool". Show you know the traps: use effective throughput, say whether latency covers failures, and note that overload with an unbounded queue never reaches a steady state, so the first fix is bounding the queue or shedding load, not computing a bigger L. Pair it with ρ and the hockey-stick curve from Queueing Fundamentals.

Model assumptions

The simulation is a simplified model, not a benchmark, and runs entirely on the lab's existing engine (nothing is scripted). Users send Poisson traffic over a 5 ms link to one API server with 8 workers, a 40 ms mean service time (lognormal, cv 0.3) and a bounded queue (100 waiting requests; 20 in the effective-throughput step; effectively unlimited in the overload step), so it can finish about 200 requests per second; the way back is another 5 ms. The boundary is the user's view: a request is in the system from the moment it is sent until its answer or failure returns. L is the time-average number of such requests, sampled every 100 ms over the last 5 simulated seconds; W is the mean latency and λ the throughput of requests that succeeded in that window (population: successes only, window: 5 s). λ × W is computed from those two tiles. The 4.8 busy workers and 0.1 waiting requests in the boundary step are the same law applied to other boundaries; they are stated in the text and checked in the lesson's tests, not shown as tiles. Rejected requests are in the system for a few milliseconds and are in L but not in W, a small difference the effective-throughput step mentions. Averages over a 5 s window fluctuate by several percent; the text rounds accordingly. In the overload step the simulation runs at normal speed so the growth is visible; the model has no timeouts or retries there, which a real client would add. Numbers show behaviour and orders of magnitude only. Latency percentiles and averages are computed over successful requests; failed, rejected and timed-out requests are counted in the Errors tile, which is always shown next to them.

The lesson as textEvery step of the simulation, written out.
  1. 1. Three numbers, one equation

    Pick a boundary around a system. Count the requests that cross into it per second (λ, the throughput), how long each one stays inside on average (W, the time in the system) and how many are inside at any moment on average (L).

    Little’s law says that for a stable system: L = λ × W. Here users send about 50 requests per second; each spends about 50 ms in the system (5 ms to the server, 40 ms of work, 5 ms back). So on average 50 × 0.05 s = 2.5 requests are in the system. Compare the L tile with λ × W: they agree.

    No distribution, no arrival pattern and no queueing discipline is assumed. It is an accounting identity about averages.

    Scene: Users send about 50 requests per second to an API server. Each request spends about 50 milliseconds in the system, so on average about 2.5 requests are in it. The tiles show throughput, time in the system, the measured average number in the system, and throughput times time, which match.

    Key idea: L = λ × W: average number in the system = throughput × average time in the system, for any stable system and any boundary.

  2. 2. Worked example: how many requests are in progress?

    Traffic rises to 120 per second. Without running anything, predict L.

    1. λ = 120 requests per second (every request succeeds, so offered and completed are the same). 2. W = 51 ms: the server is only about 60% busy, so requests rarely wait; 5 + 40 + 5 plus a little. 3. L = 120 × 0.051 s ≈ 6 requests in the system.

    Now read the tiles: L ≈ 6. The same sum sizes things: to keep 6 requests in progress you need at least 6 workers (or connections), and that is without headroom for bursts. The server has 8, which is why it is 60% busy.

    Scene: At 120 requests per second each request still spends about 51 milliseconds in the system, so on average about 6 requests are in it. The measured average equals throughput times time in the system.

    Key idea: Two of the three numbers give you the third. Use L = λ × W to size concurrency: workers or connections ≥ λ × time spent in service, plus headroom.

  3. 3. Why L grows faster than the traffic

    Now 180 per second, 50% more than before. L does not grow by 50%: it roughly doubles. Both factors of L = λ × W rise: λ went up, and W rose too because the server is about 90% busy and requests start to queue (queueing delay grows like ρ ÷ (1 − ρ), see Queueing Fundamentals).

    The law still holds: L ≈ λ × W on the tiles. It only says how the three numbers relate, not why W changed. This is why connection pools and thread pools that were fine at 120 per second can be exhausted at 180: the concurrency you need grows faster than the traffic does.

    Scene: At 180 requests per second the server is about 90% busy. Requests start to wait, so the time in the system grows and the average number in the system rises by much more than 50 percent compared with 120 requests per second.

    Key idea: L = λ × W is always true; when load rises, W often rises with it, so L (and the concurrency you must provision) grows faster than λ.

  4. 4. Use the same boundary for all three numbers

    Back at 120 per second. The law holds for any boundary, but L, λ and W must describe the same one.

    - The user’s view (from “send” to “answer”): W = 51 ms, L = 120 × 0.051 ≈ 6. - Only the server’s workers: a request occupies a worker for the 40 ms of service, so L = 120 × 0.040 = 4.8 busy workers: exactly what the server’s 60% utilisation of 8 workers means. - Only the waiting line: Wq is a millisecond or two, so Lq ≈ 120 × 0.001 ≈ 0.1.

    Mixing boundaries gives nonsense: multiplying 120 by the user’s 51 ms and calling the result “busy workers” overstates them (6 instead of 4.8), and dividing the server’s 4.8 by λ and calling that “latency” gives 40 ms, which misses the 10 ms of network.

    Scene: At 120 requests per second the same system gives two correct answers for two boundaries: about 6 requests between send and answer from the user’s view, and about 4.8 busy workers inside the server, where each request stays only for its 40 milliseconds of work.

    Key idea: Define the boundary first, then measure λ, W and L on that boundary. A different boundary is a different, equally valid, equation.

  5. 5. λ is the rate that gets through, not the rate offered

    Traffic jumps to 260 per second, more than the 200 per second the server can finish. The queue is limited to 20 waiting requests, so the server rejects about a fifth of the requests. Look at the first two tiles: Offered ≈ 260, Throughput ≈ 200.

    Which one belongs in L = λ × W? The one that matches W. W is measured over the requests that were served (≈ 140 ms: they wait behind a full queue), so use their rate: 200 × 0.14 s ≈ 28, which is what the L tile shows. Using the offered 260 gives ≈ 35, about 25–30% too high: the rejected requests never stayed in the system long (they were turned away after the network trip).

    The latency tiles also count only successful requests. The Errors tile (about 20%) is the other half of the story.

    Scene: At 260 requests per second the server can only finish about 200 and rejects the rest because its queue is full. Served requests wait about 140 milliseconds. Average number in the system matches throughput of served requests times their time, about 28, and not offered traffic times time, about 36.

    Key idea: Use the effective throughput (what actually completes) with the latency of the requests that completed. Offered traffic that was rejected is not part of that flow.

  6. 6. Unbounded overload: the law has nothing to settle on

    Same 260 per second, but the queue is now unbounded and nothing is rejected. Watch W and L: they do not settle. The backlog grows by about 60 requests per second (260 in, 200 out), so each request waits a quarter of a second longer than the one before it every second, and L keeps climbing. Slow the clock down or speed it up and every reading changes: there is no “the” value to read off.

    The naive reading (“throughput is 200, W is 8 s, so L = 1,600, done”) fails twice. The averages are only meaningful if the system is stable (arrivals ≈ departures, L bounded, the long-run averages exist), and here λ(arrival) > capacity so none of that holds. And even over a short window the figures disagree: requests still waiting are in L but not yet in W, so L stays about 30% above λ × W and the gap never closes.

    Little’s law does not fail; it is just not a prediction here. Fix the system (shed load, add capacity, bound the queue) before you reason with steady-state numbers.

    Scene: With no limit on the queue, nothing is rejected but the backlog grows by about 60 requests per second. The time in the system and the average number in the system keep rising instead of settling, and the average number stays above throughput times time. There is no steady state to read.

    Key idea: L = λ × W describes stable systems. When arrivals exceed capacity and the queue is unbounded, L and W grow without limit and any steady-state reading is an artefact of when you looked.

  7. 7. Using the law without fooling yourself

    Back to 120 per second with a bounded queue: stable, L ≈ 6, and the tiles agree.

    Before using L = λ × W, check four things: the boundary (the same one for all three numbers), λ (the effective throughput, not the offered rate), W (the time of the requests counted in λ, and say which population: successes only here) and stability (arrivals ≈ departures, nothing growing without bound). Then it sizes pools, thread counts and connection limits, and sanity-checks any measurement: if your monitoring shows L, λ and W that do not agree, one of them is measured on a different boundary or the system is not in steady state.

    Scene: Back at 120 requests per second with a bounded queue: stable, about 6 requests in the system on average, and the measured average equals throughput times time in the system.

    Key idea: Boundary, effective throughput, a stated latency population, stability: check all four, then L = λ × W is a reliable sanity check and sizing tool.