Try
↑ ↓ move↵ openesc close
In this lesson · topic 5 of 7
  1. 1. Why the average lies
  2. 2. Histograms, merging and honest load tests
  3. 3. Average the hosts, widen the buckets, stop waiting
  4. 4. When an averaged p99 is half the real one
  5. 5. How many requests stand behind a p99
  6. 6. Turning latency into a good-events ratio
  7. 7. Fifty hosts, one stall, one bucket choice

Topic 5

How many requests stand behind a p99

7 min read

A p99 on a dashboard looks like a fact about the service. It is also a fact about one window of requests, and how many requests that window held decides how far you can trust it.

The requests above the line

Take a service that handles 10 requests a second. A one-minute window holds 600 requests. The p99 is the value that 99 percent of them beat, so six requests sit above it. The number on the chart is set by where those six land.

Now give the service a small slow path: one request in 200 takes two seconds, the rest take about 20 ms. The slow share is 0.5 percent, so the true p99 is on the fast path, near 40 ms. But the slow requests do not arrive on a schedule. In a given minute you expect three of them, and the count varies from minute to minute.

Using the nearest-rank definition, the reported p99 turns slow only when more than six requests in the window are slow, because only then does the slow group reach below the six-request line. With 600 requests and a 0.5 percent slow share, that happens in about 3 percent of minutes. It is rare enough to look like a glitch and common enough to show up daily.

Raise the slow share to exactly one percent and the picture changes completely. The same arithmetic gives a 39 percent chance that any given minute reads slow. The chart flickers between 40 ms and two seconds with no change in the service at all. At two percent the p99 is slow in 96 percent of minutes and stays there.

Predict first

A service sees 600 requests a minute and one request in a hundred is slow, independently. In roughly what share of one-minute windows will the p99 read as slow?

Thinner windows, thinner tails

A p99.9 over the same window sits above only the single slowest request. Six hundred requests cannot define a 99.9th percentile at all, so the value you see is that minute’s maximum, whatever the tool calls it. The fixes are to widen the window, merge across hosts before reading the percentile, or alert on a count such as “more than 20 requests over two seconds in five minutes”, which does not wobble like a percentile of a thin window.

Windows over time combine like hosts

The rule from the host example applies to time. The p99 of an hour is not the average of sixty per-minute p99s. Store per-minute histograms and add the sixty before reading the percentile. If you kept only the percentiles, their maximum is an upper bound on the hourly p99, and nothing better is recoverable.

Suppose fifty-nine quiet minutes read 40 ms and one busy minute reads two seconds. The average is 73 ms. The real hourly p99 depends on how many requests that one minute held, and the average ignores that weight, just as it ignored traffic share across hosts.

As a rough guide, not a standard, want about 100 requests above the cut. A p99 then needs around 10,000 requests in its window and a p99.9 needs around 100,000. Below that, widen the window or choose a lower percentile.

Sources

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms