Course map

Topic 101 / Advanced

Little's Law, queueing fundamentals and Amdahl's Law

Chapter 6.5 · Performance Analysis

What and why

Tail latency (→ 100) rises sharply as a system approaches capacity, and two results from queueing theory make that precise instead of anecdotal. Little's Law relates the number of requests in a system, the rate they arrive, and how long each stays: L = λW (mean number in the system = arrival rate × mean time in the system) — true for any stable system. Amdahl's Law bounds how much adding parallel workers can speed up a task with an unavoidably serial part: speedup is capped by that serial fraction no matter how many workers are added. Builds on: → 100 (latency, throughput and tail latency).

Diagram

Little's Law: L = λ · W                 Amdahl's Law: S(n) = 1 / ((1−p) + p/n)
λ = arrival rate (req/s)                p = parallelizable fraction
W = mean time in system (s)             n = number of workers/machines
L = mean number in system               S = speedup over 1 worker
  (concurrency)                         max speedup as n → ∞ is 1 / (1 − p)

How it works

  1. Little's Law applies to any stable queueing system — a request queue, a connection pool, a thread pool: the average number "in" the system (queued or being served) equals the arrival rate times the average time each one spends there.
  2. It gives a sizing rule in either direction: given a target latency W and an expected arrival rate λ, the system needs capacity for at least L = λW concurrent requests; given a fixed pool size C and a known service time W, the maximum sustainable arrival rate is λ_max = C ÷ W — beyond that, requests queue and wait grows without bound.
  3. As utilization (arrival rate ÷ service capacity) approaches 1, queueing delay rises sharply, not linearly — this is why systems are planned below roughly 70–80% utilization, leaving headroom before the curve bends upward (the same bend behind → 100's tail-latency spikes under load).
  4. Amdahl's Law addresses a different question: once there's enough capacity, how much does adding more parallel workers actually help? If a fraction p of the work can be parallelized and (1 − p) cannot, speedup from n workers is capped at 1 ÷ ((1 − p) + p/n).
  5. As n grows without bound, speedup approaches 1 ÷ (1 − p) — a hard ceiling set entirely by the serial fraction; past a certain n, adding more machines buys almost nothing, so the serial part must be found and reduced before further scaling is worth the cost.

Practical example

(numbers illustrative). A service has a thread pool of 30 threads; each request holds a thread for 0.3 s. Maximum sustainable throughput = 30 ÷ 0.3 = 100 req/s. If 80% of a request's total work can be parallelized and 20% is an unavoidable serial step, adding 4 machines yields speedup = 1 ÷ (0.2 + 0.8/4) = 1 ÷ 0.4 = 2.5× — not 4×. Even with unlimited machines, speedup caps at 1 ÷ 0.2 = 5×: the 20% serial fraction alone bounds every future scaling effort.

When to use it

  • Use Little's Law to size any pool, queue, or instance count from a target latency and known arrival rate, or to compute the maximum throughput a fixed-size pool can sustain.
  • Use Amdahl's Law before buying more machines for a parallelizable workload — find the serial fraction first.
  • Avoid treating either as exact prediction for a highly variable, bursty workload — both describe averages over a stable system; a system that's never actually stable needs headroom and backpressure (→ 97) on top of the formula, not instead of it.
  • Failure scenarios: sizing a pool exactly at λ_max with no headroom, so any burst above average pushes utilization to 1 and latency toward infinity; adding machines to a workload whose serial fraction was never measured, paying for capacity Amdahl's Law already said wouldn't help; mistaking a system that's merely slow (high W, stable) for one that's unstable (λ > capacity, queue growing without bound) — Little's Law only holds for the stable case.
  • Simpler alternative: for a system far below capacity with low variance, a rough headroom rule ("keep utilization under 70%") may be enough without computing L or W explicitly.

Practice

(numeric drills — 20 min; compute by hand, then verify).

  1. Arrival rate λ = 100 req/s, mean time in system W = 0.2 s. Find the mean number of requests in the system, L.
  2. A system is observed to hold L = 50 concurrent requests with mean time in system W = 0.5 s. Find the arrival rate λ.
  3. A connection pool has capacity C = 30, mean hold time W = 0.3 s. Find the maximum sustainable arrival rate λ_max. If actual arrivals run at 120 req/s, what happens?
  4. 80% of a workload is parallelizable, 20% is serial. Using Amdahl's Law, find the speedup with n = 4 workers.
  5. Same workload (p = 0.8). Find the maximum possible speedup as n → ∞.

Answer key: (1) L = 100 × 0.2 = 20. (2) λ = 50 ÷ 0.5 = 100 req/s. (3) λ_max = 30 ÷ 0.3 = 100 req/s; at 120 req/s (> λ_max) the pool is overloaded — requests queue and wait grows without bound, it does not simply "run 20% slower." (4) S(4) = 1 ÷ (0.2 + 0.8/4) = 1 ÷ 0.4 = 2.5×. (5) S(∞) = 1 ÷ (1 − 0.8) = 1 ÷ 0.2 = 5×.

Done when all five answers match the key.

Key takeaway

Little's Law sizes pools and queues from arrival rate and latency and explains why delay explodes near full utilization; Amdahl's Law caps parallel speedup at the serial fraction, however many machines are added. Done when you can: compute pool size or max throughput from Little's Law, and compute capped speedup from Amdahl's Law, for given numbers. Used next in → 102 (capacity planning, applying both to real growth), → 103 (profiling, finding the serial fraction and the saturated resource in practice); Project 13 (sizing the feed read path).

References

None — this topic makes no external claims.

Source directory
Python workbench — run this lesson's numbers

Edit the code and press Run. Python 3.14 loads right in your browser the first time you run (a one-time download of about 15 MB; after that it works offline); the code itself never leaves this page.

Search the guide