Skip to content
WebsiteHosting.com

concept Operations & procedures

Histogram buckets and misleading percentiles

To estimate p95 across instances, add request counts at matching bucket boundaries first. The counts establish a range; a specific latency inside it depends on an interpolation assumption.

Latest recorded source check · P0188

What it means

A latency histogram can tell you which range contains the 95th percentile (p95), but not exactly how long a request at that position took. A classic histogram keeps counts at duration cutoffs rather than individual request times. To estimate p95 across instances, add the counts at matching cutoffs first. Averaging the instances’ p95 values answers a different question.

Try it

Simulation: start with the two synthetic instances below, with B’s bucket boundaries set to same and scenario evidence set to provided. Change only the percentile from 95 to 100. Watch which cutoff, if any, accounts for enough requests to reach the new target rank.

Histogram buckets and misleading percentiles

Explain bucket boundaries, aggregation and quantile approximation limits

Simulation
Modeled outcome: Estimate

Compatible cumulative counts are added before a uniform-within-bucket interpolation. The resulting quantile is an estimate, not the exact empirical quantile.

Histogram buckets and misleading percentiles: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
Merged cumulative histogram and quantile bracket

Quantile

  1. Rank104.5
  2. Lower bound (ms)100
  3. Upper bound (ms)200
  4. Merged estimate (ms)198.75
  5. Mean of estimates (ms)195
Upper boundaryAcumulative countBcumulative countMergedcumulative count
100 ms60565
200 ms9510105
+Inf10010110

The cumulative buckets are 100 ms, 200 ms and +Inf. The estimate interpolates within a finite bucket; an open bucket has no finite upper estimate. Averaging per-instance estimates is not a merged percentile.

Evaluated inputs

Required scenario evidence
provided
A ≤100 ms
60 count
A ≤200 ms
95 count
A +Inf count
100 count
B first boundary count
5 count
B second boundary count
10 count
B +Inf count
10 count
B bucket boundaries
same
Quantile percentile
95 %

Classic cumulative counts for nonnegative durations, fixed common 100/200/+Inf boundaries. Uniform interpolation estimate (fractional rank, not nearest rank); approximate unweighted mean of individual estimates for counterexample only. Unknown/overflow intentionally gives null rather than mimicking Prometheus highest-bucket fallback. No counter-rate resets, native histograms or exact raw quantiles.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

InstanceAt or below 100 msAt or below 200 msAll requests (+Inf)
A6095100
B51010
Merged65105110

Read each column as a count, not a duration. The counts are cumulative: the 105 requests that finished within 200 ms already include the 65 that finished within 100 ms. The +Inf count is the total, not the number of slow requests.

At p95, the target rank is 0.95 × 110 = 104.5. The 100 ms cutoff covers only 65 requests, but the 200 ms cutoff covers 105, so the simulation places p95 in the range above 100 ms through 200 ms and estimates 198.75 ms. At p100, the target rank rises to 110. Five requests took longer than 200 ms, and there is no higher finite cutoff to say how much longer. The result is above 200 ms, with no finite estimate. Reset restores both original rows, matching boundaries, provided evidence, and p95.

Where 198.75 ms comes from

There are 105 − 65 = 40 requests in the range above 100 ms through 200 ms. The p95 target is 104.5 − 65 = 39.5 positions into those 40. The simulation assumes the requests are spread uniformly across that 100 ms span. It therefore moves 39.5/40 of the way from 100 ms to 200 ms: 100 + (39.5 / 40) × 100 = 198.75 ms. The fractional rank sets the interpolation distance; there is no request numbered 104.5.

How far could that estimate be from a recorded time? Imagine that all 40 requests in that range took 101 ms. In a sorted list of the raw times, the 105th request (rounding the p95 position up for this comparison) would take 101 ms, so the estimate would be 97.75 ms too high. If all 40 instead took 200 ms, it would be 1.25 ms too low. Both sets of times fit exactly the same bucket counts. The range comes from the counts; the decimal places come from the assumption.

Estimating each instance’s p95 separately gives 200 ms for A and 190 ms for B. Their simple average is 195 ms. That average gives each instance one vote, even though A handled 100 requests and B handled 10. More fundamentally, the two percentile values alone don’t tell you how many requests from each instance finished by each cutoff. Those counts are what locate the combined rank.

Change the requested percentile to 50 with the same merged counts. The rank is 55 of 110 and the first finite cumulative count is 65 at 100 ms. Linear interpolation within that bucket gives about 84.62 ms. The actual sample values remain unknown; a compatible bucket estimate is not a reconstructed observed median.

A rank exactly equal to a cumulative cutoff belongs to that inclusive finite bucket, even when the next bucket is open-ended. The model compares the integer rank numerator with 100 times the cumulative count before interpolating.

In practice

Before combining classic histograms, check the cutoffs, not just the number of columns. In Prometheus, the le label identifies the inclusive upper bound of a classic bucket. Keep le when summing buckets across instances for histogram_quantile, so each sum still refers to one cutoff. If B’s boundaries are different or unknown, the simulation will not merge the rows by position. If the total is zero, there is no percentile to estimate; that is not a latency of zero.

Sometimes the counts answer the operational question without interpolation. If the objective is “at least 95% of requests finish within 200 ms,” the example gives a direct answer: 105 of 110 did, which meets the threshold. For a cutoff of 150 ms, the same table tells you only that between 65 and 105 requests qualified. It does not establish whether the objective was met at that cutoff.

This simulation uses nonnegative durations and fixed cumulative counts. It does not calculate rates, handle counter resets, model native histograms, or measure a live service. When reporting latency, use a count if the question names a recorded cutoff. If the question asks for a combined percentile, report the bucket range and distinguish what the counts establish from what interpolation adds.

Frequently asked questions

Editorial questions based on the listed sources and explicitly labeled local examples.

Can histograms aggregate?

With compatible bucket definitions, counts can be combined.

Can you average percentiles?

Not generally to recover the aggregate percentile. Combine compatible histogram counts first and estimate the quantile from that distribution; the mean of per-instance estimates does not recover the combined distribution.

Why narrower buckets near SLO?

Narrower compatible buckets near the decision boundary constrain the quantile more tightly. Interpolation still estimates the distribution within a bucket rather than recovering individual observations.

What if the quantile lands in +Inf?

The open-ended bucket provides no finite upper bound. This lab reports the estimate as unknown; Prometheus histogram_quantile instead uses its defined estimate based on the next-lower finite boundary. Neither is an exact recovered sample.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. Prometheus histograms and summaries

    Quantiles from histograms. Classic histograms can be aggregated by summing compatible cumulative buckets; quantile estimates depend on distribution assumption within a bucket. No averaging of instance quantiles for global quantile.

    Checked .

  2. Prometheus: Query functions

    histogram_quantile. Prometheus classic histogram aggregation preserves the le label. A calculated quantile interpolates within buckets and does not reconstruct the original observations.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.