P99 Latency: What It Means and How to Measure and Cut It
p99 latency is the value 99% of requests beat. See a worked calculation, why fan-out makes it matter, how many samples you need, and how to set a p99 gate.
p99 latency is the response time that 99% of requests meet or beat, so the slowest 1% take longer. If your p99 is 800 ms, one request in a hundred needed more than 800 ms. It matters because users and calling services meet that slow 1% far more often than the number suggests.
Prerequisites
- Raw response times or histogram bucket counts for the operation you care about.
- A stated workload: arrival rate or virtual user count, and the steady-state window.
- A target percentile and limit, from an SLO or a latency budget.
Define p99 precisely
A percentile is a rank in a sorted list. Sort every response time from fastest to slowest. The p99 is the value at the position below which 99% of the observations fall. Unlike the mean, it ignores how large the slow values are. It only tells you where the slowest 1% begins.
Two conventions are common. The nearest-rank method takes the value at rank ceil(0.99 × n). Other tools interpolate between two neighbouring values. On large samples the two agree. On small samples they differ by a lot, so write down which one your tool uses before you compare numbers across tools.
Calculate p99 on a small sample
Take 20 hypothetical response times in milliseconds, sorted:
12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 22, 24, 26, 29, 35, 48, 120, 950
Using nearest rank with n = 20:
- p50: rank
ceil(0.50 × 20)= 10, so 19 ms. - p95: rank
ceil(0.95 × 20)= 19, so 120 ms. - p99: rank
ceil(0.99 × 20)= 20, so 950 ms. With 20 samples the p99 is the maximum. - Mean: the values add up to 1,452, and 1,452 / 20 = 72.6 ms.
The mean sits at 72.6 ms, close to nothing that any request experienced. The median says the service is fast. The p99 says one request in this batch took almost a second. The example also shows a limit: 20 samples do not describe a 1% tail, because the “tail” is one observation.
Know which percentile answers which question
| Percentile | What it describes | When to use it |
|---|---|---|
| p50 | The typical request | Spotting broad slowdowns and comparing releases |
| p95 | The slowest 5% start here | Common SLO and test-gate metric, enough samples in short runs |
| p99 | The slowest 1% start here | Fan-out paths, interactive journeys, strict objectives |
| p99.9 | The slowest 0.1% start here | High-volume services where one in a thousand is still many users |
Higher percentiles need more traffic to measure. A p99.9 from a 5,000-request run rests on the slowest 5 requests. Choose the percentile by traffic volume and by how much a bad request costs, not by habit. The latency tolerance guide covers how to pick the limit that goes with the percentile.
Why p99 matters more than 1% suggests
One request in a hundred sounds rare. It stops being rare when a single user action touches many backends. If each call has a 99% chance of finishing under its p99, the chance that all N calls do is 0.99^N, and the chance that at least one call lands in the tail is 1 − 0.99^N.
| Calls per user action (N) | Chance at least one call is in the slowest 1% |
|---|---|
| 1 | 1.0% |
| 5 | 4.9% |
| 10 | 9.6% |
| 50 | 39.5% |
| 100 | 63.4% |
This assumes the calls are independent, which real systems only approximate. A page that waits on 100 calls feels the backend p99 on about 63% of loads. The service’s p99 is the typical experience of the whole page. Tail latency and fan-out goes further into how this compounds across services.
How many samples a stable p99 needs
A p99 is only as steady as the number of observations above it. With n samples, about 0.01 × n of them sit in the tail. The question is how often a window contains no sample above the true p99 at all, in which case your measured value comes out too low. That probability is 0.99^n:
- n = 100: 0.99^100 = 36.6%
- n = 300: 0.99^300 = 4.9%
- n = 1,000: 0.99^1000 is below 0.01%
So 100 samples give an estimate that falls short of the real p99 about a third of the time, while 1,000 samples almost never miss the tail entirely. Missing the tail entirely is the extreme case. A stable number needs more than one tail sample, so plan for thousands of requests in each window you want to judge. For short ramp steps, either lengthen the step, raise the arrival rate, or judge p95 and report p99 as informational.
Never average percentiles
The mean of two p99 values is not the p99 of the combined traffic. Suppose worker A serves 3,000 requests with a p99 of 500 ms and worker B serves 2,000 requests with a p99 of 1,400 ms. A plain mean gives 950 ms and a weighted mean gives 860 ms. Neither is the combined p99. You know only that it lies between 500 and 1,400 ms. The same rule applies to time windows: a p99 per minute averaged over an hour is not the p99 of the hour.
To combine, keep the raw samples, or merge histogram bucket counts and read the percentile from the merged distribution. Bucket width then sets your precision near the p99. The histogram reading guide shows how to choose buckets and keep an overflow count.
Watch for coordinated omission
A load generator that waits for each response before it sends the next request slows down exactly when the system slows down. That hides the tail. Say the plan is 10 requests per second for 60 seconds, which is 600 scheduled requests, and the service stalls for 10 seconds. A waiting client records one 10-second response and then carries on, so about 500 recorded samples hold one slow value, which is 0.2% and leaves p99 untouched. The schedule says 100 requests should have started during the stall, 16.7% of the run, each delayed by up to 10 seconds, which puts the true p99 close to 10 seconds.
Measure latency from the scheduled send time, or use an open workload model that keeps arriving at the planned rate. The coordinated omission guide explains both fixes.
Measure and gate p99 in a load test
- Choose the boundary. Decide what you time (the client round trip, the server alone or a full journey) and keep that choice across runs.
- Derive the target. Start from an SLO or a latency budget, and write it as
p99 < X ms at Y requests per second for operation Z. - Size the window. Work out how many requests the steady-state stretch will produce. Aim for at least a few thousand per window you gate on.
- Hold the workload. Use a stated arrival rate or virtual user count, and exclude warm-up from the judged window.
- Judge at test level and by label. Check the critical operation on its own, because a blended p99 hides a slow write behind fast reads.
- Compare with the p50 and p95 from the same run. A p99 many times the p95 points to a separate population, so read the histogram next.
- Repeat the run. If the p99 moves a lot between identical runs, the sample is too small or the environment is unstable. See performance test thresholds for choosing gates that stay quiet when nothing changed.
Reduce a high p99
Find the cause before you tune. Common ones:
- Garbage collection or runtime pauses: the pause length shows up as a flat plateau in the tail.
- Queueing: requests wait for a worker, a connection or a thread. The tail grows sharply as utilisation approaches the limit.
- Cold caches: first requests after a deploy or an eviction miss and take the slow path.
- Lock contention: a hot row or a shared mutex serialises a subset of requests.
- Retries and timeouts: a retry after a timeout adds the full timeout to the request, so the tail sits near the timeout value.
- Noisy neighbours: shared hosts or shared databases add delay that no request controls.
Match the evidence to the cause. A cluster of slow requests near one value suggests a timeout or a pause. A slope that steepens with load suggests queueing. Slow requests that share a key suggest contention. Use distributed traces from the slow requests to see which span carries the time, change one thing, then rerun with the same workload.
Troubleshooting
- The p99 changes a lot between identical runs. The window holds too few samples. Lengthen the step or raise the arrival rate.
- The p99 equals the maximum. You have fewer than 100 samples. Collect more before you judge.
- The p99 looks fine but users complain. Check for coordinated omission and for a blended result that hides one slow operation.
- Per-worker p99 values disagree with the total. Merge the samples or bucket counts. Never average the percentiles.
- The tail disappears when you add tracing. The tracing agent changes timing. Compare with and without it.
A worked example
These numbers are hypothetical. A checkout API under a steady 200 requests per second for 5 minutes produces 60,000 requests. The run reports p50 of 85 ms, p95 of 240 ms and p99 of 1,100 ms. The slowest 1% is 600 requests, enough to analyse.
The p99 is 4.6 times the p95, so the tail looks like a separate population. The histogram shows a small cluster of requests between 900 and 1,300 ms. Traces for those requests show a 900 ms wait on a connection pool sized at 20. At 200 requests per second with a 100 ms average database call, about 20 connections are busy on average, so any burst queues. After raising the pool to 40 and rerunning, the p99 drops to 380 ms in the same scenario, with p50 and p95 almost unchanged. The objective was p99 < 800 ms, which now passes with margin. The gap between p95 and p99 told you where to look, and the second run confirmed the cause.
Read percentiles in MaxoPerf
MaxoPerf reports latency as a distribution. The run Overview shows time-series lines for p50, p90, p95 and p99, and the Latency overview chart shows the percentile distribution. You also add failure criteria on a test: pick a metric, a comparator and a threshold, and a run that breaches a criterion is marked failed. The failure criteria cookbook walks through the setup using p95 latency, and the latency percentiles guide explains how to read the charts. When you set a gate on a high percentile, apply the sample-size check above to the window it judges.
Questions this article answers
What is p99 latency?
p99 latency is the response time that 99% of requests meet or beat. The slowest 1% take longer. If p99 is 800 ms, one request in a hundred needed more than 800 ms.
What is a good p99 latency?
There is no universal number. A good p99 is one that stays under the limit your users or calling services tolerate for that operation. Derive it from an SLO or a latency budget, then check that the p99 holds at your peak load.
Why is p99 latency higher than p50?
p50 describes the typical request. p99 describes the slowest 1%, which often include cache misses, garbage collection pauses, queueing and retries. A wide gap between the two means the slow requests follow a different path from the typical ones.
How many requests do you need to measure p99 reliably?
You need enough requests that the slowest 1% contains many samples. With 100 requests, the chance that no sample lands above the true p99 is about 37%. With 1,000 requests it drops below 0.01%, and a stable estimate usually needs thousands per window.
Do you average p99 values from several load generators?
No. The average of per-worker p99 values is not the p99 of the combined traffic. Merge the raw samples or the histogram bucket counts, then compute the percentile once.