What do latency, throughput, p50 and p90 mean? Given 10 request latencies of milliseconds, what are the p50 and p90, and why do production systems promise p99 rather than the average?
ML system design, Estimation
Level L1 Beginner. Length Short. Nature Th+Mat Both.
What's being asked
Whether you know the basic serving-speed terms, can compute a percentile by sorting, and understand why tail latency matters more than the mean.
Key idea
Latency is how long one request takes, while throughput is how many requests the system handles per second. Percentiles measure what fraction of requests are at least that fast: p50 is the median and p90 is the 90th percentile, so p99 captures the slow tail that averages hide.
Steps
- Define latency and throughput: latency is the time from sending one request to getting its answer, measured in ms (milliseconds). Throughput is the rate of completed requests, such as QPS (queries per second).
- Explain p50 and p90: p50 (the 50th percentile) is a time threshold such that 50% of requests finish at or below it. Similarly, p90 (the 90th percentile) means 90% of requests finish at or below that time, leaving the slowest 10% above it.
- Sort the 10 latencies in ascending order so you can read off ranks: .
- Apply the nearest-rank convention for sorted items: p50 is at rank , which is , and p90 is at rank , which is . (For comparison, the mean is .)
- Explain why systems promise p99 (the 99th percentile) instead of the average: a few very slow requests hurt user experience and cause timeouts, even when 90% of requests are fast and the average looks fine. Harder capacity-estimation questions build on this to size servers from QPS and tail-latency budgets.
Common mistakes
- Forgetting to sort the numbers before picking the 5th or 9th item.
- Confusing latency with throughput; higher throughput does not automatically mean lower latency per request, especially if batching adds waiting time.
- Reporting only the mean latency in a design review, which hides a 1-in-100 slow spike that breaks downstream timeouts.
How long your answer should be
About 2 minutes; definitions plus one short sort.
Read this
Previous in ML system design: How do you turn a vague business goal such as 'increase engagement on a video app' into an ML objective, offline metrics, online metrics and guardrail metrics?
Next in ML system design: When can you cache a machine learning model's predictions to save compute, and when is caching a bad idea?