KatInterview

Design an Enterprise Metrics Aggregation and Alerting Platform

System DesignModel answer
EasyModel answerSystem Designsystem-designtime-seriesstream-processing

Last updated

Design a scalable, highly available observability system that ingests 1M data points per second, supports low-latency querying across retention tiers, and executes real-time alert conditions.

Problem Overview

Design a scalable enterprise metrics collection, storage, and alerting platform tailored for a multi-tenant microservices topology. The platform must continuously ingest high-frequency telemetry from thousands of running service hosts, render dashboard visualizations, and trigger alert notifications when metrics breach defined operational parameters.

Core Requirements

Functional Scope

  1. Ingestion: Accept incoming raw telemetry tuples: (timestamp, metric_name, service_id, value, labels).
  2. Multi-Resolution Queries: Expose querying APIs for operational dashboards, seamlessly stitching together high-resolution real-time data and aggregated long-term data.
  3. Automated Alerting: Continuously evaluate complex rule definitions (e.g., Service latency metric exceeds 200 ms across the 95th percentile over a 5-minute sliding window) and deliver notifications.

Non-Functional & Scale Scope

  • Ingestion Scale: Sustained load of 1,000,000 metric data points per second (1M events/sec), with capacity for 3x peak bursts during rolling deployments or major incidents.
  • Retention Tiers:
    • 1-second granularity stored for 7 days.
    • 1-minute downsampled rollups stored for 1 year.
  • Performance Targets: Dashboard rendering queries must complete in under 1 second. Alert generation latency (time from event occurrence to rule evaluation) must remain within 30 seconds.
  • Fault Tolerance: High availability with zero single points of failure. Ingestion pipeline failure must not cause host application degradation. High-precision alerting must execute reliably even if individual ingestion worker nodes crash.

Instructions

Prepare a comprehensive architectural design covering:

  1. Capacity Planning: Back-of-the-envelope estimations for network bandwidth, uncompressed/compressed storage capacity, and memory footprint.
  2. Ingestion & Data Flow Architecture: High-level pipeline diagram detailing client-side collection, buffering, stream processing, and storage components. Contrast push vs. pull telemetry architectures.
  3. Data Model & Storage Engine Selection: Database paradigm choices, time-series storage index structure (e.g., TSDB head blocks, inverted index, columnar layouts), and downsampling strategies.
  4. Stream-based Alerting Engine: Real-time stream evaluation architecture, window management strategies (tumbling vs. sliding), state persistence, and alert deduplication/flapping management.
  5. System Resilience & Trade-offs: Fault isolation, backpressure handling, and consistency vs. availability trade-offs under network partition scenarios.

Hints

Hint 1

Calculate total unique time series count by estimating metric cardinality (metric name combined with set of key-value labels). Compression heavily depends on series ordering.

Hint 2

Using standard relational databases (RDBMS) for append-heavy time-series workloads leads to massive index maintenance overhead. Evaluate specialized LSM-tree or Gorilla-compressed columnar engines instead.

Hint 3

For alerting at scale, avoid periodically polling the database for thousands of rules. Evaluate rule definitions directly against incoming event streams in memory using sliding window state stores.