← Lessons

quiz vs the machine

Gold1380

Concurrency

The Little Law Applied to Threads

Using the relation between concurrency, throughput, and latency to size a system.

5 min read · core · beat Gold to climb

A law that always holds

Little law says that in a stable system the average number of items in flight equals the arrival rate times the average time each item spends in the system. Written for a server:

  • concurrency equals throughput times latency

It holds for any stable system regardless of internal detail, which makes it a powerful sanity check.

Sizing threads with it

If you need a throughput of two thousand requests per second and each request takes fifty milliseconds, then the average in flight count is two thousand times zero point zero five, which is one hundred. You need at least one hundred slots of concurrency in flight, whether that is threads or async tasks.

Spotting impossible plans

  • If a pool has fifty threads but each request takes one hundred milliseconds, the most throughput it can sustain is fifty divided by zero point one, which is five hundred per second.
  • Asking it for two thousand per second is impossible without either more concurrency or lower latency.

The law turns hand waving into arithmetic.

Key idea

Little law ties concurrency to throughput times latency, so you can compute the in flight count a target load demands instead of guessing.

Check yourself

Answer to earn rating on the learn ladder.

1. What does Little law state for a stable server?

2. A pool of 50 threads serves requests that each take 100 ms. What throughput can it sustain?

3. What must change to raise sustainable throughput without breaking the law?