Design a Time Series Metrics Database
Design a high-cardinality metrics database for durable ingestion, range queries, rollups, late data, and retention.
Problem statement
For this exercise, assume telemetry producers append timestamped numeric metric points and authorized users query metric ranges with tag filters and fixed time-bucket aggregations. A series is identified by a metric name plus a canonical tag set.
Producers attach a stable point ID, may retry, and may deliver points up to ten minutes late or out of order; older corrections use an explicit backfill job.
The service must ingest high-cardinality traffic durably, serve recent dashboard queries quickly, retain raw points for thirty days, and retain five-minute and hourly rollups for thirteen months. Query results should include an as-of watermark so callers can distinguish complete from still-open time ranges.
Alert evaluation, logs, traces, arbitrary joins, and active-active multi-region writes are outside scope.
What to build
- Producers can batch-ingest versioned metric points idempotently and receive a durable acceptance outcome.
- Authorized clients can query one or more matching series over a time range and receive raw points or a supported bucket aggregation with an as-of watermark.
- The database incorporates in-window out-of-order points and executes explicit, auditable backfills for older corrections without silently losing or double counting data.
- The system continuously builds five-minute and hourly rollups and expires raw and aggregate data according to the stated retention policy.
At scale
- For this exercise, assume five million ingested points per second across up to one hundred million active series.
- For this exercise, common dashboard queries read the latest twenty-four hours and should complete within two seconds at p95, while wider historical scans may be asynchronous or slower.
- For this exercise, acknowledged points must survive a process or single-zone failure; producers deliver at least once, and the system may expose a short ingestion watermark lag rather than fabricate complete results.
- For this exercise, raw points are retained for thirty days, while five-minute and hourly aggregate rollups are retained for thirteen months.