Module 1 · FundamentalsLesson 9 of 887 minBeginner
Latency and throughput
Latency is how long one request takes. Throughput is how many you can finish per second. Push one too far and the other suffers.
Start at 3 requests a second, then slowly drag the traffic up. Watch the response time stay flat, then suddenly climb, and finally watch requests get dropped.
Two numbers describe how a system performs.
Latency is how long a single request takes, start to finish. Measured in milliseconds.
Throughput is how many requests the system finishes per second.
They're related but not the same. A highway can carry thousands of cars an hour (throughput), while each car still takes 30 minutes to get home (latency).
Why waiting time explodes
When a server is lightly loaded, each request gets served straight away. As traffic grows, requests sometimes arrive while the server is busy, so they wait in a queue.
The surprising part: waiting time doesn't grow evenly. At 50% busy, a request rarely waits. At 90% busy, it often waits behind several others. At 99%, the queue is long and keeps growing with every burst. That's why engineers aim to keep servers well below full, around 60 to 70% at peak.
And when the queue is full, the server has to drop requests, which users see as errors.
Averages lie
If 99 requests take 50 ms and one takes 5 seconds, the average is about 100 ms, which looks fine. But that one user waited 5 seconds.
So teams track percentiles:
- p50: half of requests are faster than this (the typical experience),
- p95: 95% are faster (the slow-but-common case),
- p99: 99% are faster (the worst experience most users ever see).
A page that makes 20 backend calls hits each service's p95 almost every time, so tail latency matters a lot in big systems.
Typical numbers to keep in mind
- Reading from memory: under a microsecond
- Reading from an SSD: about 0.1 ms
- A round trip inside one data centre: about 0.5 ms
- A round trip across a continent: 40 to 80 ms
- A round trip across the world: about 150 to 250 ms
Distance often costs more than computing.