Section 18.1.8

Mean, median, and the chosen performance question

Definition

The mean of a set of measured durations is their total divided by their number, and the median §11.13 is their middle value after sorting. They answer different performance questions. The mean answers how much time the requests cost on average: the number of requests times the mean gives back their total time. The median answers what a request in the middle of the sorted list experiences: at least half of the requests take no longer. Report the statistic that answers the question asked, chosen before the data are seen.

Where it fits

Main entry: Sample mean (§11.12).

The sample mean entry and the median entry treat each statistic in full; this entry is about choosing between them. Take five invented request durations of 1, 1, 1, 1 and 96 milliseconds (ms). Their total is 1+1+1+1+96=1001 + 1 + 1 + 1 + 96 = 100 ms, so the mean is 100/5=20100 / 5 = 20 ms. The third of the five sorted values is 1, so the median is 1 ms. No request took 20 ms, yet the mean answers the capacity question of how much server time the requests need: 5×20=1005 \times 20 = 100 ms. The median describes the typical request, and the one slow request does not move it.

Some questions need neither statistic. For a deadline question, report the fraction of requests that meet the deadline: four of the five finish within 10 ms, a fraction of 4/5=0.84 / 5 = 0.8, or 80%. For the slow end of the distribution, called the tail, report a high percentile §11.16 (a value that a stated percentage of the requests do not exceed) or the maximum, and state how many requests that value rests on. Neither 20 ms nor 1 ms states any of these numbers.

Limits and common mistakes

A mean bar beside a median bar, whether for two systems or for an earlier and a later figure, compares answers to two different questions, so the difference in height is not a performance difference.

The mean is not wrong because one extreme value moves it; that sensitivity is what makes the mean track total cost. Removing the 96 ms request as an outlier §11.31 would cut the total work of the example from 100 ms to 4 ms and the mean from 20 ms to 4/4=14 / 4 = 1 ms.

A request that failed, or that hit its timeout §9.34 (the time limit after which the client stops waiting), has no completion time. Leaving such requests out makes every summary look better than what users experienced, so report how many there were. A request that hit its timeout is a censored observation §11.28: its duration is known only to exceed the limit.

Questions answered

Which statistic should be reported?

Report the statistic that answers the question being asked, chosen before the data are seen. The mean, the total of the durations divided by their number, answers questions about total or average cost per request. The median, the middle duration after sorting, answers what a middle-ranked request experiences, and one extreme value cannot move it far. A deadline question needs the fraction of requests that meet the deadline, and a question about rare slow requests needs a high percentile or the maximum.

For durations of 1, 1, 1, 1 and 96 milliseconds, the mean is 20 milliseconds, the median is 1 millisecond, and four of the five requests, 80%, meet a 10-millisecond deadline: three correct answers to three different questions. Report the chosen statistic with the number of requests and the number that failed.

Related entries: Median (§11.13), Quantile and percentile (§11.16), Analysis plan (§13.17), Latency distribution and tail (§11.36), Censoring (§11.28).