← Lessons

quiz vs the machine

Gold1420

System Design

Histogram Metrics

Counting observations into buckets to approximate distributions.

5 min read · core · beat Gold to climb

Beyond a single number

A gauge tells you one value, but for things like request latency you want a distribution. A histogram metric counts observations into predefined ranges called buckets.

How a histogram is exposed

A classic histogram exposes several series:

  • One counter per bucket holding how many observations fell at or below a boundary.
  • A count of all observations.
  • A sum of all observed values.

Buckets are cumulative, so the bucket for one second includes everything under one second.

Choosing boundaries

Boundaries are fixed in advance. Place them where you care about detail, often on a roughly exponential scale so a few buckets cover a wide latency range.

Trade offs

  • Histograms aggregate cleanly across instances by adding matching buckets.
  • Accuracy of derived percentiles depends entirely on bucket placement.

Key idea

A histogram counts observations into cumulative buckets plus a count and sum, giving an addable approximation of a distribution.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a histogram bucket counter hold?

2. Why do histograms aggregate cleanly across instances?