Load Balancing and the Power of Two Choices
Why sampling two servers and taking the shorter queue is exponentially better than sampling one, and why least-outstanding-requests beats round robin for variable work.
One choice
Throw balls independently and uniformly into bins. Then with probability tending to , the maximum load is
Assumptions
The matching lower bound is a second-moment argument that we do not reproduce; it is the harder half and is given in the cited literature. The upper bound is proved below, which is the direction a system designer needs — it says the imbalance is no worse than this.
With balls in bins, for ,
Consequently, taking makes this , so the maximum load is with high probability.
Two choices
Throw balls into bins, each ball choosing bins uniformly at random and going into the least loaded of them (ties broken arbitrarily). Then with probability tending to the maximum load is
Assumptions
Stated without proof; the argument is a layered-induction bound on the number of bins with load at least , given in full in the cited paper. What matters here is the shape: rather than , and a further improvement only in the constant as grows beyond two.
Simulating balls into bins, averaged over five runs:
| max load | max load | |||
|---|---|---|---|---|
| 5.8 | 3.57 | 3.0 | 2.79 | |
| 6.6 | 4.15 | 3.0 | 3.20 | |
| 7.8 | 4.71 | 3.2 | 3.53 |
Key idea
The gain from to is exponential; the gain from to is a factor in the leading term, and from onward it is diminishing. Two probes is the whole trick. This is why production balancers sample a small constant number of backends rather than maintaining a global ordering — the global information is worth almost nothing beyond what two random samples already provide, and it costs a coherency term of the kind Scaling Limits — Amdahl, Gustafson and the Coherency Penalty warns about.
What to measure when you probe
Let servers be identical and let request have service time . Round robin equalises the count of requests routed to each server. Least-outstanding-requests equalises the number currently in service. These coincide only if the are equal; in general, by Little's law applied per server, the occupancy of server satisfies
so equalising equalises the product of throughput and latency — the actual load — whereas equalising the routed count equalises alone.
Key idea
For LLM serving the service-time coefficient of variation is large — generations differ in length by orders of magnitude — so round robin and occupancy-based balancing are not close. By the Pollaczek–Khinchine formula in Queueing and the Utilisation Wall, queueing delay scales with ; routing on counts lets that variance land unevenly, while routing on occupancy absorbs it.
What this does not say
The theorems here are about static balls into bins, where balls never leave. The queueing version — the supermarket model, where jobs arrive and depart — is analysed in the second reference and has the same qualitative conclusion, with the maximum queue length under decaying doubly exponentially in the load rather than singly. The static statement is quoted because it is the one with a clean, checkable form; the dynamic statement is the one that actually applies to a serving system.
References
- PaperY. Azar, A. Z. Broder, A. R. Karlin, E. Upfal (1999). Balanced AllocationsThe theorem that two choices give log log n maximum load.
- PaperM. Mitzenmacher (1996). The Power of Two Choices in Randomized Load BalancingDevelops the fluid-limit analysis and the supermarket model for queues rather than static balls.
These works are cited as sources to read, not reproduced. All exposition, examples and problems on this site are written independently; where an argument is standard, the citation points to a canonical treatment.
Results stated on this page
- TheoremMaximum load under uniform random assignmentThrowing n balls into n bins uniformly leaves a fullest bin with about log n / log log n balls with high probability.
- TheoremThe power of two choicesSampling d bins and using the least loaded reduces the maximum load to log log n / log d plus a constant — an exponential improvement in d = 2 already.
- PropositionA log n / log log n upper bound for one choiceproof includedA first-moment argument shows uniform assignment leaves no bin with materially more than log n / log log n balls.
- PropositionRound robin ignores the information that mattersproof includedRound robin equalises request counts, which equalises load only when service times are identical; least-outstanding-requests equalises occupancy, which by Little's law tracks load.