← Lessons

quiz vs the machine

Gold1380

System Design

Downsampling and Rollups

Trading resolution for cheaper long range storage and queries.

5 min read · core · beat Gold to climb

Why reduce resolution

Raw metrics may arrive every few seconds. Keeping that resolution for years is expensive and rarely useful. Downsampling aggregates fine grained points into coarser ones, and the stored aggregates are called rollups.

How a rollup is built

For each window, such as five minutes or one hour, the system computes summary statistics over the raw points:

  • Sum and count for averaging later.
  • Min and max to preserve extremes.
  • Last for gauge like values.

Storing sum and count separately lets you average correctly even when re aggregating across windows.

Tiered resolutions

Systems keep several tiers: full resolution for recent data, then progressively coarser rollups for older data. Queries pick the coarsest tier that still answers the question fast.

Pitfalls

  • Averaging averages is wrong, so keep sum and count.
  • Percentiles do not roll up simply and need sketches.

Key idea

Downsampling builds rollups of sum, count, min, and max per window, and tiered resolutions let old data stay cheap while remaining queryable.

Check yourself

Answer to earn rating on the learn ladder.

1. Why store sum and count rather than a precomputed average?

2. Which statistic does not roll up by simple combination?