SD-10 · Back to the write-up
Design a Distributed Metrics Aggregation
Hash each series to a shard, keep 2 hours in memory, move older blocks with rollups to object storage, and cap series per tenant.
Follow a request
Write a batch
Dashboard · 7-day panel
Aggregate and compact
Fire an alert
A TSDB node dies
Sources
Edge
Pipeline
Storage
Host agentBatches every 10 s
EngineerDashboards, pages
Ingest gatewayLimits, hashing
Alert evaluatorRules every 30 s
Query frontendSplit + cache
Ingest log6 hours, 3 copies
Stream aggregatorDrops labels
QueriersFan out, merge
TSDB ingesters64 shards × 3
Limits and rulesPer tenant
Object storageBlocks + rollups
CompactorMerge, downsample
The numbers, at a glance
1 rollup360 raw points
16 BRaw
≈ 20 BWide-column cell
≈ 9 BDelta timestamps
≈ 1.5 BGorilla-style
0.6% in memory99.4% in object storage
A range query, in order
Finished days come from the cache; only today is computed.
Engineer
Query frontend
Results cache
Querier
TSDB ingesters
Object storage
1 query_range 7d, step 5m
2 get 6 finished days
3 6 hits
4 today
5 last 2 h, 3 copies
6 chunks
7 today’s 1-min blocks
8 chunks
9 today’s series
10 store today (1 min)
11 7 days of points
RequestResponseAsync, does not block
Where to aggregate
The decision this question is really about.
store every 10 s point
query sums 3,000 series
30-day panel: seconds
+ Any question later.− 30 days × 3,000 series = 777M points per refresh.
host p99host p99
average of p99s
wrong fleet p99
+ Tiny volume.− Per-host p99s cannot be combined.
raw 15 days
1-min 60 days1-h 2 years
query picks resolution
+ Recent data flexible, long ranges cheap.− More parts; dropped labels are gone.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Host agents
TSDB server
DashboardsAlerts
Host agents
Gateways
Ingest log
Sharded TSDBObject storage
Query frontendResults cache
Queriers
Sharded TSDBObject storageCompactor
GatewaysLimits and rules
Ingest log
Stream aggregatorSharded TSDB
Was this walkthrough useful?Your vote tells us what to improve next.