Video in progress
What are latency and throughput, and how are they related?
Latency is how long a single request takes (for example, 120 ms). Throughput is how many requests the system can handle per unit of time (for example, 5000 RPS). Improving one doesn't automatically improve the other.
📖 Answer
Think of a highway: latency is how long one car takes to get from A to B, throughput is how many cars pass per hour. If you widen the road, more cars get through, but each one doesn't arrive any faster.
A practical example: batching writes raises throughput (you write 1000 rows together instead of one INSERT at a time), but every record waits until the batch fills up — so latency goes up.
Measure latency with percentiles, not the average:
- p50 — half of the requests are faster than this;
- p99 — 99 out of 100 requests are faster than this.
The average can be 80 ms while p99 is 2 seconds. The user remembers exactly that slow 1%. On prod, always put p95/p99 on the dashboard.
Sign up to mark studied questions and save your progress.