Skip to content

Why Does Google Obsess Over Its Slowest 1% of Requests?

Naseebullah AhmadiSenior Software Engineer, London

Every service is healthy and the dashboard average looks great, yet support is full of customers saying the app is slow. Both are telling the truth.

4 min read
#engineering

The API dashboard says 135ms on average. An average adds every request up and divides, so a few very slow requests get spread thin across thousands of fast ones, and the people who actually waited disappear from the number.

Where the timer starts

Most backend metrics start the clock when a request reaches your server and stop it when your handler returns. Your user's clock starts when they tap the button and stops when the response is back on their screen, so it also includes the trip across the network, both ways.

@itsnas response-timeline
Server sees 135msUser waits 250msnetworkyour server
Timer runs on the
  1. 1. Request travels to you 45ms
  2. 2. Your server handles it 135ms
  3. 3. Response travels back 70ms

Measured at the server: 135ms. The user waits 250ms.

One request, segments to scale. Switch the timer between server and client: your dashboard and your user are measuring different things.

Flip the toggle and the bracket grows from 135ms to 250ms. The server number is the one you can fix in code; the client number is what people actually feel. If you only track the server side, you'll keep getting surprised by complaints from people on bad connections, so add real-user timing from the browser or app as well.

Reading percentiles

Line up 100 requests from fastest to slowest. The 95th one is your p95: 95 requests took that long or less, and 5 took longer. p50 is the median, the request in the middle. p99 is the 99th, so only one request in a hundred is slower than it.

NumberSlower than itWhat it's good for
p50halfThe typical request. If this moves, everyone feels it.
p901 in 10An early warning that a slice of traffic is getting worse.
p951 in 20A common target for alerts and SLOs on user-facing APIs.
p991 in 100The tail. What fan-out turns into an ordinary page load (more below).
p99.91 in 1,000Busy systems: at 10,000 requests a second, that's 10 slow ones a second.
maxnoneMostly noise from one GC pause or retry. Look at it, don't alert on it.
@itsnas percentiles
p50 123msp95 245msmean 135msslower than p95

p95 is 245ms: 5 of 100 requests were slower. The mean is 135ms.

100 requests to a healthy service, fastest on the left. Pick a percentile to move the cut, then switch on the slow dependency and watch which numbers notice.

Now switch on the slow dependency. It adds two seconds to 3 of the 100 requests, the kind of thing a flaky downstream service does to you:

NumberHealthySlow dependency
mean135ms195ms
p50123ms124ms
p95245ms272ms
p99275ms2,081ms

The mean jumped by about 60ms. That's enough to make you look, but it reads like everything got a bit slower, which isn't what happened. The median moved by 1ms and p95 went up a little. p99 is the only number that shows three people waiting over two seconds.

So when you pick a percentile, you're also picking whose experience you'll ignore. Put your alert on p95 and the slowest 5 requests in every 100 can get as bad as they like without it ever firing.

Two traps when reading them. Don't average percentiles across hosts: five hosts' p95s averaged isn't the service's p95. Merge the histograms and take the percentile of that (most metrics tools do this if you query the histogram). And don't trust p99 on a quiet endpoint: with 50 requests in the window, p99 is just your slowest request, so use a longer window until you have a few thousand.

One slow call in a hundred

A page load is rarely one request. The page calls a handful of services, those call a few more, and the page can't finish until the slowest of them answers. If every call is slow 1% of the time, each call you add is one more chance to land on a slow one.

@itsnas fan-out
Backend calls 10Each call slow 1%Page slow 9.6%hit its p99
Backend calls per page load
Each square is one backend call behind a single page load. Drag the slider, then send a few requests: at 100 calls, most page loads hit at least one slow call.

With 10 calls, about 1 page load in 10 is slow. With 100, it's nearly 2 in 3. Jeff Dean and Luiz Barroso described this at Google in The Tail at Scale, and it's why teams running big systems watch p99 and p99.9 so closely: once a page fans out wide enough, one service's p99 is what a normal page load feels like. The same maths works across a session. Someone who makes 50 requests in one visit has about a 40% chance of hitting your p99 at least once.

Next time a latency number lands in front of you, ask where the timer starts and what p99 looks like before you decide whether it's good.