Someone asks how fast your app is, and you have to give them a number. The average is the tempting answer, and it's the wrong one, because it describes a user who doesn't exist. p95 and p99 are the numbers that describe what people actually feel, and the gap between them tells you whether your slowest requests are rare bad luck or a real problem with your name on it.
The definitions
Sort every request's duration from fastest to slowest. With N requests, the value at position ceil(X/100 × N), counting from the fastest, is pX (the nearest-rank method). With 1,000 requests, p95 is the 950th value and p99 the 990th.
- p50 (median): half your requests are faster, half are slower
- p95: 95% of requests finished under this; 5% were slower
- p99: 99% of requests finished under this; 1% were slower
- p99.9: 99.9% of requests finished under this; 1 in 1,000 was slower. Worth tracking on payment, auth and other critical paths
Why averages lie
Take an endpoint where 98% of requests finish in 50ms and 2% take 30 seconds. The average is about 650ms, a number that describes neither group. The fast users never see 650ms; the slow users wait 600 times longer than the fast ones. The p95 is 50ms and the p99 is the full 30 seconds, so the gap between them shows the problem the average blurred.
An average blends the fast and slow requests into a duration nobody actually waited. Percentiles keep the slow requests visible.
The gap is the signal
p95 tells you the story for most users. p99 tells you the story for your most frustrated users. The gap between them tells you how frustrated those users are.
p50: 80ms
p95: 180ms
p99: 240ms
Gap p95 → p99: 60ms (small, consistent tail) p50: 85ms
p95: 220ms
p99: 3400ms
Gap p95 → p99: 3180ms (huge: about 1% of requests hit something broken) Common causes of a big p95 → p99 gap: database contention on specific rows, cache misses, garbage collection pauses, one slow downstream service affecting only some requests, uncached file reads, or (classic in Laravel) an N+1 query that fires on some pages but not others.
A worked example
Picture a dashboard endpoint that looks fine on the average: 140ms, comfortably inside its target. Its p95 is 190ms. Its p99 is 2.8 seconds.
That gap is the whole story. One in a hundred requests is doing something the other ninety-nine aren't. Pulling up a handful of the slow ones shows it: they all belong to accounts with thousands of records, and one widget loads those records without a limit. For a normal account it returns in 40ms. For the biggest tenants it scans the table.
The average never shows it. The p95 barely does. The p99 makes it impossible to miss, and the individual slow requests behind that p99 name the accounts and the query. That's the workflow worth internalizing: the percentile tells you a tail exists, the slow requests behind it tell you why.
How to pick which to optimize
In typical user-facing web apps:
- p95: your reliable SLO. Alert when it regresses; make it your latency target.
- p99: your canary. Watch the gap, not the absolute value. A widening gap is often the first sign of degradation.
- p99.9: for payment, auth, health-critical paths. Worth the operational work.
How many samples you need
Percentiles need volume before they mean anything. A p99 computed from 200 requests jumps every time one slow request lands. That's noise, not signal. One rough heuristic is to want about 100 requests beyond the percentile, which is 100 divided by (1 − percentile): about 2,000 requests before p95 settles, about 10,000 before p99 does.
In practice that makes percentiles a per-route, per-window measurement. p99 across your whole app over a day is solid. p99 for one rarely-hit admin route over an hour is mostly random. So when a percentile looks alarming, check the sample count behind it before you act on it.
How NightOwl surfaces percentiles
NightOwl stores request duration in microseconds and charts p50, p95, and p99 per route, per query pattern, and per job class. For short time windows the percentiles are exact nearest-rank values computed from the raw rows in your PostgreSQL (percentile_disc, or ORDER BY duration OFFSET ceil(n × 0.95) - 1 LIMIT 1). For wide windows a scan of every raw row timed out on busy apps, so NightOwl reads histogram rollups instead and estimates the percentile with DDSketch, which keeps it within 1% of the true value. Those charts aren't wired to alerts: a NightOwl performance alert fires when a single record (a request, job or query) crosses the duration threshold you set, so a p95 regression alert needs a scheduled query against your PostgreSQL.