Notes

Part 3 of 9

Averages, medians, and percentiles

Guess first

19 requests take about 100 ms, and one takes 2 seconds. Which number jumps more, the mean or the median?

19 requests take about 100 ms, and one takes 2 seconds. Which number jumps more, the mean or the median?
  • Response time is a spread of values, not one number. Most requests are quick, and a few outliers are much slower.
  • Variation in network delay is called jitter.
  • The average (add them up, divide by the count) helps estimate throughput limits. It is poor for "what does a normal user see", because it does not say how many people had that delay.
  • Percentiles are better. Sort all the times from fastest to slowest:

- The median (p50) is the middle one. If p50 is 120 ms, half of requests finish in under 120 ms and half take longer. It tells you how long users usually wait. - p95, p99, p999 (99.9th) show the slow end. If p95 is 900 ms, 95 of every 100 requests finish in under 900 ms, and 5 take 900 ms or more.

  • The high percentiles are called tail latencies. They matter because they directly shape what real people experience.
  • Amazon sets internal service targets at p999, even though that is only 1 request in 1,000. The slowest requests often come from customers with the most data, such as the longest order history, who tend to be the most valuable customers.
  • Going further, to p9999 (1 in 10,000), was judged too costly for too little gain. At that level, delays come from random events you cannot control.

Twenty response times

Step 1 of 5

Twenty requests to the same page, in the order they arrived. Most take 100 to 200 ms, but a few are much slower.

Try it

Mean, median and the slow tail

20 requests, 0 of them slow

Mean169 ms
Median (p50)170 ms
p95215 ms
p99215 ms

Normal requests take 80 to 220 ms here, and a slow one takes 2 s. Percentiles are read by rank: sort the times and take the one at that share of the way.

Do slow pages really cost users?

  • It seems obvious that faster is better, but solid data on how much delay changes user behavior is hard to find.
  • Some widely quoted studies mixed up causes. For example, very fast pages can look bad for sales simply because many of them are error pages with nothing on them.
  • Lesson: distrust studies that link speed to outcomes unless they control for other factors, such as what was on the page.