You store one p99 value per minute and are asked for the p99 of the whole hour for a report. What can you compute, and what should you have stored?
Sketch your own answer first, then compare it with the one below.
A strong answer
From per-minute p99s alone you can compute bounds, not the answer. The maximum of the sixty values is an upper bound on the hourly p99, because if every minute has at most 1 percent above its own p99, the hour cannot have more than 1 percent above the largest one. Nothing gives a matching lower bound that is useful.
The average is wrong, and wrong in a way that depends on traffic. If fifty-nine quiet minutes read 40 ms and one busy minute reads 2 seconds, the average is about 73 ms. The real hourly p99 depends on how many requests the busy minute held. Say 5 percent of that minute's requests were slow. If it carried a quarter of the hour's traffic, 1.25 percent of the hour's requests were slow and the hourly p99 is 2 seconds. If it carried a tenth, only 0.5 percent were slow and the hourly p99 stays near 40 ms. The average of 73 ms tells you neither.
What you should have stored are per-minute histograms, or mergeable sketches such as DDSketch. Adding sixty histograms bucket by bucket gives the histogram of the hour, and you read the percentile from that. The rule is the same as for hosts: sum the distributions, then read the percentile once.
Sources
- Charles Masson, Jee E. Rim, Homin K. Lee (2019). DDSketch: A Fast and Fully-Mergeable Quantile Sketch with Relative-Error Guarantees.
- Prometheus authors (2024). Histograms and summaries.