In Part 1 we built a backend that delivers a software update to a million cars: a load balancer, stateless application servers, database replicas, a cache, a CDN and a message queue. On paper, every part can scale. In production, the system will still have a bad morning.
Picture it: a campaign goes live at 8:00, commuters start their cars between 7:30 and 8:30, and check-ins arrive several times faster than the average we calculated. Response times creep up, then jump. Some cars time out, retry, and make it worse. Somewhere in the system one part has run out of something, and everything behind it waits.
That part is the bottleneck, and finding it is a skill every engineer needs, whether the system is a cloud backend or an ECU with a 10 ms task. This post covers the ideas that make bottlenecks predictable instead of mysterious: percentiles, utilisation and queueing, Little’s law and Amdahl’s law, followed by a walk through the 8 a.m. rush on our OTA server. As in Part 1, the system and its numbers are illustrative.
What a bottleneck is
A request to our OTA backend passes through a chain of stages: load balancer, application server, cache, database, and finally the response. Each stage can handle a certain number of requests per second, its capacity. The whole chain can never be faster than its slowest stage, just as a bottle empties no faster than its neck allows.
Take an illustrative chain: the load balancer can pass 50,000 requests per second, the application servers 8,000, the cache 100,000, and the database 1,500 on a cache miss. If 1 request in 5 misses the cache, the database sees one fifth of the traffic, so it caps the system at 7,500 requests per second, just below the application servers. Add more application servers and nothing improves, because the database is now the neck. Improve the cache hit rate instead, and the limit moves again.

Three consequences follow, and they are worth keeping in mind for every performance discussion:
- Optimising anything that is not the bottleneck is wasted effort. A faster load balancer does not help a slow database.
- Fixing the bottleneck moves it. There is always a next-slowest stage; the goal is to move the bottleneck to a place where it is cheap to scale.
- The bottleneck is a property of the workload, not just the system. A different cache hit rate, a different mix of reads and writes, or a bigger update package can move it somewhere else.
Embedded engineers know this from CPU load analysis: the task with the worst response time is rarely the one everybody is looking at.
Measure before you guess: averages lie
The first instinct when a system feels slow is to look at the average response time. It is also the least useful number you can look at. Latency distributions are not bell curves; they have a long tail on the right. Most requests are fast, a few are very slow, and the average hides both.
System engineers therefore talk in percentiles:
- p50 (median): half of all requests are faster than this. It describes the typical experience.
- p95 and p99: 95 % or 99 % of requests are faster. They describe the bad experiences that still happen thousands of times a day.
- p99.9 and max: the extreme tail, where timeouts, garbage collection pauses and lock contention live.
With a million cars checking in, “only 1 %” of slow check-ins is 10,000 cars an hour. And the tail gets worse when a request depends on several others. Jeff Dean and Luiz Barroso showed this in The Tail at Scale (2013): if each server answers in 10 ms but takes 1 second for one request in a hundred, a user request that fans out to 100 such servers will be slower than one second 63 % of the time. The rare tail of one component becomes the normal case of the whole.
The chart below shows an illustrative check-in latency distribution on a calm afternoon. The average and the median sit close together; the p99 is several times higher. When you set timeouts, size thread pools or promise a service level, it is the tail you have to plan for.

Why response time explodes near 100 % utilisation
Here is the most important and least intuitive fact in performance engineering: a resource does not slow down gradually as it gets busier. It slows down slowly, and then all at once.
The reason is queueing. Requests do not arrive evenly spaced; they arrive in random clumps. When a server is 50 % busy, a new request usually finds it idle or nearly so. When it is 90 % busy, the request almost always finds others already waiting, and it joins the queue. The closer utilisation gets to 100 %, the longer that queue becomes, and in the limit it grows without bound.

The simplest queueing model, a single server with random arrivals and random service times (called M/M/1), puts a number on it:
R = S / (1 − ρ)
where R is the average response time, S is the time to serve one request, and ρ (rho) is the utilisation. With a service time of 20 ms, the response time is 40 ms at 50 % utilisation, 100 ms at 80 %, 200 ms at 90 % and 2 seconds at 99 %. Real systems are not exactly M/M/1, but the shape of the curve, flat and then vertical, shows up everywhere.

Two practical rules come out of this:
- Do not plan to run anything near 100 %. Leave headroom; for latency-sensitive services, 60 to 70 % peak utilisation is a common target.
- Small increases in load near the knee cause huge increases in latency. A 10 % traffic spike at 85 % utilisation is not a 10 % slowdown; it can double the response time.
This is the same mathematics behind an RTOS whose CPU load creeps from 70 to 90 %: the average task still meets its deadline, but the worst-case response time of the low-priority tasks runs away.
Little’s law: how many requests are in flight
In 1961 John Little published a proof of a deceptively simple relationship that holds for almost any stable system: shops, factories, motorways and servers alike.
L = λ × W
L is the average number of requests inside the system, λ (lambda) is the arrival rate, and W is the average time each request spends inside. Nothing about distributions, nothing about the internals. It is the back-of-the-envelope tool for sizing anything that holds requests: thread pools, connection pools, queues and buffers.
Apply it to our OTA backend at 8 a.m. Suppose check-ins arrive at 1,500 per second and each one spends 40 ms in an application server. Then on average 1,500 × 0.04 = 60 requests are in flight across the application servers. Spread over 10 servers that is 6 each, comfortably below a pool of, say, 50 threads per server.
Now the database slows down and each check-in takes 400 ms instead. Same traffic, but 1,500 × 0.4 = 600 requests in flight, 60 per server. The 50-thread pools are full, new requests wait in the queue in front of them, their waiting time adds to W, and W grows further. This is how a slow component far downstream turns into connection errors at the front door.

Little’s law also works in reverse. If your database allows 100 connections and each query holds one for 20 ms, the database can serve at most 100 / 0.02 = 5,000 queries per second, however many application servers you add.
The 8 a.m. rush: hunting the bottleneck
Let us replay the bad morning step by step. The numbers are illustrative, but the sequence is a classic.

- 8:00, the campaign goes live. Commuters start their cars, and check-ins jump from a few hundred to 1,500 per second.
- The cache is cold. The campaign entry was created at 7:59, so no application server has it cached yet. Thousands of check-ins miss the cache at the same moment and all ask the database the same question. This is a cache stampede.
- The database saturates. Its connection pool is full and its CPU is close to 100 %. Following the queueing curve, query time jumps from 15 ms to several hundred milliseconds.
- Little’s law takes over. Each check-in now spends ten times longer in the application servers, so ten times as many are in flight. Thread pools fill, and new requests queue at the load balancer.
- The cars make it worse. After a 5 second timeout, each car retries immediately. The database, which was already the bottleneck, now sees the same work two or three times. This is a retry storm, and it can keep the system down long after the original spike has passed.

The chart below compares where a slow (p99) check-in spends its time on a calm afternoon and at 8:05.

The lesson for diagnosis is to follow the waiting, not the slowness. Every stage looks slow at 8:05, because every stage is waiting for the one behind it. The application servers show long response times but only 35 % CPU: they are not working, they are waiting. The database shows long response times, 98 % CPU and a growing queue. High utilisation plus a growing queue marks the bottleneck; long latency with low utilisation marks a victim. Good dashboards therefore show, for every resource, three things side by side: utilisation, saturation (queue length or wait time) and errors.
The fixes follow from the diagnosis:
- Warm the cache before the campaign starts, and let only one request per key go to the database on a miss while the others wait for its answer (request coalescing).
- Roll out in waves: 1 % of the fleet, then 10 %, then everyone. This is good safety practice for OTA anyway, because a bad update hits fewer cars.
- Spread the check-ins. Add a random offset to each car’s check-in time instead of letting a million cars wake up on the hour.
- Retry politely: exponential backoff with jitter, a cap on the number of retries, and timeouts based on measured percentiles. The Amazon Builders’ Library article on this is one of the best short reads on the topic.
The usual suspects
Bottlenecks are rarely original. The same handful show up in system after system, and each one has a recognisable signature.
| Suspect | What you see | Typical fix |
|---|---|---|
| Database connections | Requests wait for a connection; the database CPU may even be idle | Right-size the pool with Little’s law; shorter transactions; read replicas |
| A hot key or partition | One cache node or database shard at 100 %, the rest idle | Spread the key (add a suffix, replicate it), cache it locally, rethink the partition key |
| Cache stampede | Database spike right after a cache entry expires or a deployment | Pre-warm, request coalescing, staggered expiry times |
| Thundering herd | Huge spike at round times (on the hour, after an outage) | Random jitter on schedules and reconnects |
| Retry storm | Load stays high after the original problem is gone | Exponential backoff with jitter, retry budgets, retry at one layer only |
| Slow downstream dependency | Thread pools full, CPU low, timeouts at the edge | Timeouts from measured percentiles, circuit breakers, asynchronous calls via a queue |
| Lock contention | CPU low, throughput flat however many threads you add | Smaller critical sections, partitioned data, lock-free structures |
| Garbage collection or memory | Periodic latency spikes, p99 much worse than p50 | Reduce allocation, tune heap, or move hot paths out of managed code |
Two habits make these easier to find. First, measure every resource with the three questions from the previous section: how busy is it, how much work is waiting for it, and how often does it fail. Brendan Gregg calls this the USE method: utilisation, saturation, errors. Second, remember that retries multiply across layers: the Amazon article above shows that with three attempts at each of five layers, a struggling database can see up to 243 times the original load (3 to the power of 5).
Amdahl’s law: why adding servers stops helping
The natural reaction to a bottleneck is to add machines. Sometimes that works perfectly, and sometimes it does almost nothing. Gene Amdahl explained why in 1967.
Any workload has a part that can be spread across machines and a part that cannot: one primary database that takes every write, a global lock on the campaign counter, a single coordinator that assigns rollout waves. If a fraction p of the work can be parallelised and the rest cannot, then with n machines the best possible speedup is:
S(n) = 1 / ((1 − p) + p / n)
The serial part sets a hard ceiling of 1 / (1 − p), however many machines you add. If 95 % of the work scales, 10 machines give a speedup of about 6.9, 100 machines about 16.8, and no number of machines will ever get you past 20. The chart below shows the curves for a few values of p.

The practical message is the same as in the rest of this post, seen from a different angle: find the part that does not scale and attack it directly. For our OTA backend, that means keeping single points of coordination out of the hot path. Install reports go into the queue rather than straight into the primary, the campaign counter is updated in batches by the workers rather than locked by every check-in, and read traffic goes to replicas and caches. Part 3 of this series looks at the tools for removing serial parts altogether: stateless scaling, partitioning (sharding) and the consistency trade-offs that come with them.
What I take away
- There is always exactly one bottleneck at a time. Find it before you optimise anything else, and expect it to move once you fix it.
- Look at percentiles, never just averages. The p99 is where your users, and your timeouts, actually live.
- Keep away from the knee. Latency stays flat until utilisation gets high, then explodes. Plan for headroom, not for 100 %.
- Use Little’s law to size every pool and queue. Arrival rate times time in system tells you how many slots you need, and why a slow dependency fills them.
- Follow the waiting, not the slowness. High utilisation plus a growing queue is the bottleneck; everything else is a victim.
- Spread the load in time. Waves, jitter, backoff and pre-warmed caches are cheaper than servers, and for OTA they are good safety practice too.
Further watching and reading
- ByteByteGo, How Can Cache Systems Go Wrong?: a one-page visual of cache stampedes, penetration and avalanches.
- ByteByteGo, Which Latency Numbers Should You Know?
- ByteByteGo, Scalability Simply Explained in 10 Minutes, a good bridge to Part 3.
- Jeffrey Dean and Luiz André Barroso, The Tail at Scale: the classic paper on why tail latency dominates large systems.
- Marc Brooker, Timeouts, retries and backoff with jitter in the Amazon Builders’ Library.
- Brendan Gregg, The USE Method, a checklist for finding bottlenecks in any system.
Sources
- Dean and Barroso, The Tail at Scale (2013), Google Research, example summarised in the morning paper
- John D. C. Little, A Proof for the Queuing Formula L = λW, Operations Research 9(3), 1961
- Little’s Law as Viewed on Its 50th Anniversary (2011)
- Amazon Builders’ Library, Timeouts, retries and backoff with jitter (2019)
- Brendan Gregg, The USE Method
- Gene M. Amdahl, Validity of the single processor approach to achieving large scale computing capabilities, AFIPS Spring Joint Computer Conference, 1967
- System Design, Part 1: The Building Blocks
The OTA backend, its capacities and latencies, and the 8 a.m. scenario are illustrative, not measurements of a real system. Cover photo by Nabeel Syed on Unsplash.
Pingback: System Design: 1 - The Building Blocks, Explained Through a Car Update Server - Taner Güngör