tezvyn:

Why tail latency (p99) matters

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

Tail-latency reasoning.

OUTLINE

averages hide the worst experiences, and fan-out amplifies tails so most requests touch a slow path; causes include GC pauses, queueing, contention, and noisy neighbors.

WHAT THIS TESTS: Whether you grasp that user experience is governed by the tail of the latency distribution, not the average, and can name the mechanisms that create it.

WHY TAIL LATENCY MATTERS: The average and p50 describe a typical request but hide the slowest ones, and those slow requests hit real users, often your most engaged ones with the most data. More importantly, in a fan-out architecture a single user request triggers calls to many backends and must wait for all of them; the overall latency is governed by the slowest response among them. So a backend that is slow only one percent of the time will make a request touching one hundred backends slow most of the time. This amplification means a rare per-component tail becomes the common end-to-end experience at scale.

COMMON CAUSES: Garbage collection or other stop-the-world pauses, queueing delay and head-of-line blocking when a slow request stalls others, lock and resource contention, cold caches and cache misses, retries and timeouts stacking up, noisy neighbors on shared hardware, and variance in network, disk, or background tasks like compaction.

COMMON WRONG ANSWERS: Optimizing the average, dismissing p99 as ignorable outliers, or assuming tail latency is purely random rather than caused by identifiable mechanisms.

LIKELY FOLLOW-UPS: How do you reduce tail latency, hedged requests, tied requests, better isolation? How does fan-out math work? Why measure p99.9 too? How does load relate to the tail?

ONE CONCRETE EXAMPLE: A page renders by calling fifty microservices in parallel and waiting for all. Each service is fast at p50 but has a one-percent chance of a slow response from a GC pause. The probability that at least one of fifty is slow is roughly forty percent, so nearly half of page loads are slow despite every service looking healthy on its average. Fixing the tail, by tuning GC and adding hedged requests, improves p99 dramatically even though the averages barely move.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.