Utilisation and queueing
Busy means slow
Section titled “Busy means slow”Utilisation is the share of a service’s capacity that is in use: the rate at which requests arrive divided by the rate at which the service could serve them. Four servers that each take 20 ms can serve 4 ÷ 0.020 = 200 requests per second. At 100 requests per second they are 50% utilised.
A natural guess is that time in the service grows in proportion to the load: twice as busy, twice as slow. It does not. Requests arrive at random, so sometimes several arrive close together, and when the servers are busy they have to wait. The busier the servers are, the more likely a request finds them all occupied and the longer it takes for the backlog to clear.
Mental model. Spare capacity is what drains a queue. When it is plentiful, queues are short and clear at once. When it is nearly gone, one small burst leaves a queue that takes a long time to clear, and meanwhile new requests join it.
Here is the arithmetic. The four servers above can serve 200 requests per second. A burst leaves 50 requests waiting. Requests keep arriving, so the queue drains at the rate of capacity minus arrivals.
| Utilisation | Arrivals | Spare capacity | Time to clear 50 waiting requests |
|---|---|---|---|
| 50% | 100 per second | 100 per second | 0.5 s |
| 95% | 190 per second | 10 per second | 5 s |
| 99% | 198 per second | 2 per second | 25 s |
Same burst, same servers. The only difference is how much spare capacity there was, and the clearing time grows fiftyfold.
The shape of the curve
Section titled “The shape of the curve”For one server whose service times are exponentially distributed, the mean time in the system is the service time divided by (1 − utilisation). A server that takes 10 ms to serve a request, run at different loads:
| Utilisation | Times the service time | Mean time in the system |
|---|---|---|
| 50% | 2 | 20 ms |
| 70% | 3.3 | 33.3 ms |
| 80% | 5 | 50 ms |
| 90% | 10 | 100 ms |
| 95% | 20 | 200 ms |
| 99% | 100 | 1,000 ms |
Going from 50% to 80% makes requests two and a half times as slow. Going from 80% to 99% makes them twenty times as slow. The curve is gentle for a long way and then climbs almost vertically. It has no upper limit: at 100% and above the queue grows for as long as the load lasts.
Try it: the curve for your own settings
Section titled “Try it: the curve for your own settings”The lab below draws the curve for a service with a queue shared by several servers. Your current load is marked on it, and the table gives the levels worth knowing for your other settings. The lab starts with the four servers of 20 ms from before.
Requests arrive at a service with a few servers that share one queue. Raise the arrival rate toward what the servers can serve and watch the time a request spends in the system: it rises slowly at first and then sharply. Change the number of servers, the service time, and how much it varies.
Each dot stands for many requests. The numbers show the real rate.
No bottleneck: every component has headroom.
Response time at this load
- Utilisation
- 50%Busy
- Mean time in the system
- 21.7 ms1.1× the service time
- 99th percentile
- 95.3 ms95th percentile: 63 ms
- Requests in the system
- 2.20.2 of them waiting
Little's Law: 100 requests per second × 21.7 ms = 2.2 requests in the system on average.
Time in the system as utilisation rises
- Mean
- 95th percentile
- 99th percentile
A line that leaves the top of the chart keeps going up: the time grows without limit as utilisation approaches 100%.
Use the left and right arrow keys to move along the curve, and shift with an arrow to move ten points. The reading is announced.
| Utilisation | Mean | Times the service time | 95th percentile | 99th percentile |
|---|---|---|---|---|
| 50% · your load | 21.7 ms | 1.1× the service time | 63 ms | 95.3 ms |
| 70% | 27.1 ms | 1.4× the service time | 75 ms | 109.9 ms |
| 80% | 34.9 ms | 1.7× the service time | 94.8 ms | 137.9 ms |
| 90% | 59.4 ms | 3× the service time | 163.3 ms | 243.9 ms |
| 95% | 109.1 ms | 5.5× the service time | 310.4 ms | 471.3 ms |
| 99% | 509 ms | 25× the service time | 1.51 s | 2.31 s |
| Component | State | Utilisation | Offered (req/s) | Served (req/s) | Rejected (req/s) | p50 | p95 | p99 |
|---|---|---|---|---|---|---|---|---|
| Clients | Healthy | <1% | 100 | 100 | 0 | 0 ms | 0 ms | 0 ms |
| Service | Busy | 50% | 100 | 100 | 0 | 16 ms | 63 ms | 95 ms |
- Traffic
- 100 req/s
- Successful
- 100 req/s
- Error rate
- 0%
- Mean latency
- 22 ms
Illustrative values, not benchmarks of any real product.
Model notes
Assumptions
- Requests arrive at random, as a Poisson process, at a constant average rate.
- Each node is one queue, served first-come first-served by several identical slots (instances × concurrency).
- Service times are random with the stated mean; by default they are exponentially distributed.
- Each node is analysed separately, with the traffic it receives treated as Poisson.
- Requests arrive independently at random, at a steady average rate, and are served in the order they arrive from one shared queue.
Simplifications
- Above capacity there is no steady state. The model switches to a fluid approximation: the node serves at capacity, its queue grows until it reaches its limit, and further requests are rejected.
- Percentiles assume an exponential tail. A service-time variability other than exponential changes the mean wait but not the shape of the tail.
- A node frees its slot as soon as it has done its own work, before waiting on the services it calls. Real thread-per-request servers hold the slot, so a slow dependency exhausts them faster than this model shows.
- A request calls its dependencies one after another. Parallel fan-out is not modelled.
- When a caller times out and gives up, the callee still finishes the work, so abandoned requests keep consuming capacity.
- Retries add load. Their backoff and jitter decide when that load arrives, which only the per-request simulation shows.
- Retry feedback is solved from the healthy starting point, so it finds one stable outcome. Systems that stay stuck in overload after the cause is gone are not shown.
- A throughput limit (for example maximum writes per second) is modelled as slower service, not as a separate rate limiter.
- A caller’s timeout counts the mean time its dependencies take, not their full distribution.
- The curve is the steady state: it assumes the arrival rate has stayed the same for long enough to settle. A real system takes time to build a queue, and a short burst can fill one even below capacity.
- Service times are exponential in shape. The variability control changes the mean wait, by a factor of (1 + variability) ÷ 2, and not the shape of the tail.
Parameter values are illustrative. They are not benchmarks of any real product.
With the defaults, read the table down the column Times the service time. At 50% a request takes 1.1 times its service time, at 70% 1.4 times, at 80% 1.7 times, at 90% 3 times, at 95% 5.5 times, and at 99% 25 times. The curve is the same shape as the one server’s, but it bends later, because four servers share one queue.
Now change one setting at a time and look at the table.
- Servers sharing the queue to 1 and Service time to 10 ms. The column now reads 2, 3.3, 5, 10, 20, 100, the table above.
- Servers sharing the queue to 8, Service time back to 20 ms. At 80% the mean time in the system is 25.7 ms, 1.3 times the service time. With four servers it was 34.9 ms, and with one server it was 100 ms. At the same utilisation, more servers sharing a queue means shorter waits.
- Back to four servers, and look at the 90% row while you move Variability of service time. At 0, which means every request takes exactly the same time, the mean is 39.7 ms. At 1, which is the default, it is 59.4 ms. At 4, which means some requests take far longer than others, it is 118.5 ms.
Three things that change the curve
Section titled “Three things that change the curve”Utilisation is the one you control by adding capacity or removing load, and it is the one with the dramatic effect, as above.
The number of servers sharing a queue. At 80% utilisation, one server takes 5 times its service time, four sharing a queue take 1.75 times, and eight take 1.29 times. A queue shared by many servers is a more flexible use of the same capacity: a request waits only if every server is busy. The comparison to make is with four separate queues, one per server, each at 80%: every one of them behaves like the single server, at 100 ms, which is nearly three times the 34.9 ms of the shared queue. The load balancing module returns to this.
The variability of the service time. When some requests take much longer than the average, they hold a server and make the ones behind them wait. In the lab at 90%, a variability of 4 doubles the mean time compared with the default, and a variability of 0 cuts it by a third. The wait grows in proportion to (1 + variability) ÷ 2, which is the correction the lab applies. Variability is what mixing cheap and expensive requests in one queue costs.
What happens if you run hot to save money?
Section titled “What happens if you run hot to save money?”A team looks at the four servers at 70% utilisation, 140 requests per second, and sees spare capacity. Running them at 95% would carry 190 requests per second on the same servers, 36% more traffic for no extra cost.
The price is in the table. At 70%, a request spends 27.1 ms in the system on average, and the 99th percentile is 109.9 ms. At 95%, the mean is 109.1 ms, four times as much, and the 99th percentile is 471.3 ms. The service carries more traffic, and each request waits four times as long.
It is also fragile. A rise in traffic of 5% moves the service at 70% to 73.5%, where the mean is 29.1 ms, a rise of 7%. The same 5% moves the service at 95% to 99.75%, where the mean is 2,009 ms, eighteen times what it was. The cost of running hot is paid in latency, and it is paid in full by the first small surge. Headroom is not waste: it is what the latency goal is made of.
How much to keep is a decision, not a constant. It depends on the number of servers, on how much service times vary and on the goal. With the four servers of the lab, a goal of “99th percentile under 250 ms” is met up to 90% and broken at 91%, as the lesson on percentiles found. A goal that must hold through a surge needs room to absorb the surge.
Seeing it in a real system
Section titled “Seeing it in a real system”Brendan Gregg’s USE method gives a checklist for any resource: its utilisation, its saturation and its errors. Utilisation is how busy it is. Saturation is the extra work it cannot serve right now, which often waits in a queue. The lab’s curve links the first two: saturation is negligible at low utilisation and grows without bound as utilisation approaches 100%. This is why a high-utilisation reading is worth acting on even when nothing has failed yet, and why the SRE book lists saturation among the four signals to watch.
- Utilisation is arrivals divided by capacity. Time in a service grows slowly at low utilisation and sharply near 100%, because spare capacity is what drains a queue.
- For one exponential server the mean time in the system is the service time divided by (1 − utilisation): 2 times at 50%, 10 times at 90%, 100 times at 99%.
- With four servers of 20 ms sharing a queue, the mean is 21.7 ms at 50% and 59.4 ms at 90%, and rises to 509 ms at 99%.
- More servers sharing one queue flatten the curve: at 80% the mean is 5 times the service time for one server, 1.75 for four and 1.29 for eight.
- Variable service times steepen it: at 90% the mean is 39.7 ms with none, 59.4 ms by default and 118.5 ms with a lot.
- Running hot buys throughput with latency, and a small surge near 100% costs the most. Headroom is what the latency goal is made of.
Next: bottlenecks, and how to find the part that limits the whole system.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.