Can You Average Two p95 Latencies?
To find the p95 across two servers, pool their requests or merge compatible histograms. Even a request-weighted average of the two p95 values can be far from the pooled result.
Follow the 95th request
Imagine that two servers complete 100 requests between them in one minute. Sort all 100 latencies from fastest to slowest. Under the nearest-rank convention, p95 is the latency in position 95, counting from one.
| Server | Completed requests | Latency of each request | Server p95 |
|---|---|---|---|
| A | 96 | 10 ms | 10 ms |
| B | 4 | 1,000 ms | 1,000 ms |
The first 96 positions all hold 10 ms, including position 95. So the pooled p95 is 10 ms. Averaging the two server values gives 505 ms. Weighting them by request count gives 49.6 ms. In this particular example 49.6 ms is the mean request time.
Change just two requests
Run this example with Python 3. Increasing B's share from four to six requests moves the 95th observation across the boundary. Both servers still report the same individual p95 values.
from math import ceil
def nearest_rank_p95(samples):
ordered = sorted(samples)
return ordered[ceil(0.95 * len(ordered)) - 1]
for slow in (4, 5, 6):
samples = [10] * (100 - slow) + [1000] * slow
print(slow, nearest_rank_p95(samples))
| Slow requests | Pooled p95 |
|---|---|
| 4 | 10 ms |
| 5 | 10 ms |
| 6 | 1,000 ms |
At exactly five slow requests, an interpolating percentile estimator may produce a different result. Record the estimator when comparing small samples. An empty time window has no empirical percentile.
What to keep for a dashboard
With raw latencies, compute the percentile over all requests in the chosen window. With classic histograms, retain counts for the same bucket boundaries, unit and time window across servers. Add the counts for each boundary before estimating the quantile. If the 95th request lands in a wide bucket, its precise latency remains unknown. A threshold question such as “what fraction finished within 200 ms?” can instead be answered directly when 200 ms is a bucket boundary. Prometheus histogram guidance
If only per-server p95 values were recorded, label them by server. To compare two releases, keep the request mix and observation window alongside the result. Recording a performance baseline
Sources
Revision history
- Published
- Updated
- — Added a reproducible two-server example and a histogram interpretation.