Blog

Sampling beacons without skewing percentiles

Dropping beacons at random is easy. Keeping p95 honest while you do it is the hard part.

Large publishers send us tens of millions of page views a month. Storing every one at full resolution is rarely useful: a p75 LCP computed from two million samples is indistinguishable from one computed from twenty million.

The catch is that naive sampling hurts the tail. If you keep one beacon in ten uniformly, the slowest one percent of page views, the ones that matter most, is represented by a handful of points per day on a small page.

Our pipeline therefore samples per page and per day, never globally. Pages below a volume threshold are kept in full. Above it, the rate drops gradually and every kept beacon carries a weight, so counts and percentiles are computed from weighted values.

We checked the approach by replaying a month of traffic from three large sites at several sampling rates and comparing the percentiles with the unsampled values. At the default rates the p75 differed by less than 1 % and the p95 by less than 2.5 %.

← All articles