"Average response time: 120ms" is one of the most comforting and least useful numbers on a dashboard. The average is dragged down by the mass of fast requests and tells you nothing about the slow tail where real users live. If one request in a hundred takes two seconds, the average barely moves — and that request might be your biggest customer's checkout.
Percentiles describe the tail honestly. The p99 is the value under which 99% of requests fall: "99% of requests were faster than 850ms". You cannot average percentiles across servers or time buckets, which is the mistake that quietly corrupts most dashboards. The correct way is to record a histogram of latencies and compute the percentile from the merged buckets.
// bucketed histogram, not an average
hist := prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "http_request_duration_seconds",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5},
})
start := time.Now()
// ... handle request ...
hist.Observe(time.Since(start).Seconds())
There is a subtler trap: coordinated omission. If you measure latency by firing a request, waiting for the reply, then firing the next, a slow server reduces its own request rate while it is struggling, so your load generator never records how bad the backlog really was. The result is a p99 that looks great under exactly the overload you were trying to measure.
The cure is to send requests on a fixed schedule regardless of when replies come back, and to count the time a request spent waiting to be sent as part of its latency. Load tools like wrk2 do this for you. Until you account for it, your tail latencies are optimistic, and optimism is not what you want from the number that defines your SLO.