Latency and Throughput
Fast vs much.
Two numbers describe how fast a system is. Latency is how long one request takes. Throughput is how many requests the system handles each second. They sound alike, but they're different.

- Latency: how long one takes
- Throughput: how many per second
- Not the same thing
A road analogy
Think of a road. Latency is how long one car takes to drive from one end to the other. Throughput is how many cars pass each minute. Adding more lanes raises throughput, but each car still takes the same time. To lower latency, you need a shorter or faster road.
Latency
- Time for one carMeasured in millisecondsLower is better
Throughput
- Cars per minuteRequests per secondHigher is better
Averages hide problems
We usually measure latency with percentiles, not averages. Here are ten response times. Run it. The average looks fine, about one hundred and sixty five milliseconds. But the ninetieth percentile shows that one in ten users waits much longer. That's why engineers watch P ninety nine, the slowest one percent.
times = [90, 95, 100, 102, 98, 110, 105, 97, 99, 750] # ms
avg = sum(times) / len(times)
ordered = sorted(times)
p50 = ordered[len(ordered) // 2]
p90 = ordered[int(len(ordered) * 0.9)]
print(f"average: {avg:.0f} ms")
print(f"p50: {p50} ms")
print(f"p90: {p90} ms")average: 165 ms p50: 100 ms p90: 750 ms
Summary
Latency is time per request, and throughput is requests per second. Measure latency with percentiles, because averages hide slow users. Next, how slow common operations really are.
Key takeaways- Latency in ms
- Throughput in requests/sec
- Watch p99, not the average