In this lesson · topic 5 of 7
Topic 5
The knee in the queueing curve
7 min read
The lab shows that tails grow with load. Queueing theory gives the exact shape, and you can do the arithmetic on paper.
One server, random arrivals
Take one server with exponential service times, mean 1 t, and Poisson arrivals at utilization ρ. This is the M/M/1 queue. A request’s total time in the system is exponentially distributed with mean 1 / (1 − ρ), so the 99th percentile is ln(100) / (1 − ρ), about 4.6 / (1 − ρ).
| Utilization | Mean time | p99 |
|---|---|---|
| 0.50 | 2 t | 9.2 t |
| 0.80 | 5 t | 23 t |
| 0.90 | 10 t | 46 t |
| 0.95 | 20 t | 92 t |
| 0.99 | 100 t | 461 t |
Nothing in the table is a threshold. The curve is a hyperbola, so each step closer to 1 costs more than the last. From 0.90 to 0.95 you add five points of load and double the mean wait.
Predict first
Variable request sizes add a multiplier
Real requests are not exponential. For a single queue with Poisson arrivals and any service-time distribution, the Pollaczek-Khinchine formula gives the mean wait before service starts: ρ (1 + C²) / (2 (1 − ρ)), in units of the mean service time, where C is the coefficient of variation of service time.
At ρ = 0.85:
- C = 0, every request costs the same: 2.8 t of waiting.
- C = 1, exponential: 5.7 t.
- C = 1.5, the lab’s default: 9.2 t.
The lab default waits more than three times as long as constant-cost requests at the same utilization. Random assignment splits a Poisson stream into independent Poisson streams, so each server in the lab is close to this M/G/1 queue, and its mean time in the system is about 10 t. The lab adds a speed spread and discrete ticks, so treat that as an order of magnitude, not a prediction.
Pooling servers
Eight servers at 0.85, each with its own queue, behave like eight copies of the single-server case. Mean time in the system is 6.7 t with exponential service. Now give the same eight servers one shared queue, so any idle server takes the next request. This is M/M/8. The Erlang C formula says 57 percent of arrivals wait at all, the mean wait is only 0.48 t, and the mean time in the system is 1.5 t. Pooling is more than four times better, with the same hardware and the same load.
You usually cannot have one shared queue, because it needs a central dispatcher and an extra hop. Least connections and power of two choices are ways to get part of the pooling benefit without it. They steer a request away from a long queue, which is what a shared queue does automatically. That is why they close so much of the gap in the lab.
Sources
- Mor Harchol-Balter, Performance Modeling and Design of Computer Systems, Cambridge University Press, 2013.
- Michael Mitzenmacher, The Power of Two Choices in Randomized Load Balancing, IEEE Transactions on Parallel and Distributed Systems, 2001.