Capacity with Little's law

Performance and scaling Mid-level Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Predict the output

What do the two lines print?

Python 3.13
arrival_rps = 200
time_in_system_s = 0.25
in_flight = arrival_rps * time_in_system_s
print(in_flight)  # requests being served at any moment

per_worker_rps = 1 / time_in_system_s
print(arrival_rps / per_worker_rps)  # workers needed at 100% busy

Options
Hint 1 of 1

L = λ × W

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A 50.0 then 50.0

Correct. 200 × 0.25 = 50 in flight; each worker handles 4 per second, so 50 workers.

Little's law says L = λ × W: 200 per second × 0.25 s gives 50 requests in flight. One worker finishes 4 a second, so 50 workers keep up only at 100% busy.

Why not the others?
  • B 50.0 then 4.0. 4 is each worker's rate, not the worker count.
  • C 800.0 then 50.0. Multiply rate by time, don't divide.
  • D 200 then 50. These are float divisions and products.

30-second answer

Little's law says the average number of requests in the system equals arrival rate times average time in the system: L = λW. At 200 requests per second taking 0.25 s each, about 50 are in flight at any moment, so you need at least 50 workers (threads, connections or async slots) just to keep up, plus headroom because servers run badly near 100% utilisation and queues grow sharply as load approaches capacity.

Practise saying it · 30 s. No recording, just a timer

Size a service.

Say your answer out loud, then check which of these points you covered:

  • L = λW
  • Workers ≥ in-flight
  • Headroom to ~70%
  • Latency raises L

Deep dive

It holds for any stable system, regardless of the arrival distribution.

Size database pools with it: queries per second × query time.

Plan for utilisation around 60–70% so bursts don't explode queue times.

If latency rises under the same load, L rises too, so pools can exhaust in a feedback loop.

Little's law arithmetic Ran on Python 3.13.5 · mypy --strict
Python 3.13
arrival_rps = 200
time_in_system_s = 0.25
in_flight = arrival_rps * time_in_system_s
print(in_flight)  # requests being served at any moment

per_worker_rps = 1 / time_in_system_s
print(arrival_rps / per_worker_rps)  # workers needed at 100% busy

Common mistakes

  • Sizing pools by guesswork.
  • Planning for 100% utilisation.
  • Ignoring that slow dependencies raise W and therefore L.

Senior take & follow-ups

State L = λW, do the arithmetic, then add headroom and the latency feedback loop.

Follow-up questions

Think of your answer first, then open the hint.

  1. A dependency slows from 50 ms to 500 ms. What happens to in-flight requests?

    Show hint

    They grow tenfold at the same arrival rate.

  2. Why headroom?

    Show hint

    Queueing delay rises steeply near full utilisation.

Suggest a fix if something here is wrong or out of date.