Library

Volume 1 · System Design Scenarios

Notebook
Sign in

Section 54

Real-Time IoT Analytics Platform (1M Events/Sec)

399 words · about 2 min

Problem Statement

Design a platform ingesting up to 1,000,000 telemetry events/second from distributed IoT devices, with near-real-time dashboards (<5s delay), 90-day hot retention, and anomaly-based alerting.

Scale Math

1M events/sec x ~500 bytes/event average payload ~= 500 MB/sec ingest
Daily volume: 1M/s x 86,400s ~= 86.4 billion events/day
90-day retention at that rate: ~7.8 trillion events (partition/compact aggressively;
  raw retention beyond ~7 days is normally downsampled to rollups)

Architecture

IoT Devices (millions) -> MQTT/AMQP -> IoT Hub / Event Hubs (Kafka-compatible)
                                            |  (partitioned by device_id, 200+ partitions)
                         +------------------+------------------+
                         v                  v                  v
                  Stream Analytics    Flink/Spark          Raw archival
                  (hot path:          Structured           (Event Hubs
                   1-min rollups,      Streaming             Capture ->
                   threshold alerts)   (enrichment,          Parquet in
                         |              windowed agg)         Data Lake)
                         v                  v                      |
                  SignalR push       Time-series DB           Batch analytics
                  (live dashboard)   (Azure Data Explorer /   (Spark/Synapse
                                      TimescaleDB /            on Parquet,
                                      InfluxDB)                 90-day cold
                         |                  |                   queries)
                         v                  v
                    Live Dashboard    Grafana / Power BI
                                            |
                                    Anomaly Detection
                                    (statistical + ML model,
                                     scores each rollup window)
                                            |
                                    Alert routing (PagerDuty/
                                    Teams/SMS via Service Bus)

Key Design Decisions

  • Event Hubs over Service Bus: Service Bus tops out far below 1M events/sec; Event Hubs (or self-managed Kafka) is purpose-built for this throughput, using partitioned logs and consumer groups for parallel processing.
  • Partition key = device_id (or device_id hash): preserves per-device event ordering while spreading load evenly; avoid partitioning by a low-cardinality field like region (creates hot partitions).
  • Dual-path processing (Lambda architecture): a hot/speed path (Stream Analytics or Flink) for sub-5-second dashboards and threshold alerts, and a cold/batch path (Parquet in a data lake, queried via Spark/Synapse) for 90-day historical analytics — trying to serve both from one system either kills latency or kills cost.
  • Time-series database, not a general RDBMS: Azure Data Explorer / TimescaleDB / InfluxDB are built for high-cardinality time-indexed writes with automatic downsampling/retention policies — a normal SQL table would need constant manual partition management at this volume.
  • Backpressure handling: if consumers fall behind, Event Hubs buffers (bounded retention, e.g., 24-72 hours) rather than dropping data; auto-scale consumer instances on partition lag (KEDA), and shed low-priority telemetry (e.g., verbose debug metrics) first under sustained overload.

Non-Functional Targets

Requirement Target
Ingest throughput 1M events/sec sustained, 1.5M burst
Dashboard latency < 5 sec end-to-end
Alert latency (critical) < 2 sec
Hot storage retention 7-14 days (queryable at full resolution)
Cold storage retention 90 days (downsampled to 1-min/1-hr rollups)
Availability 99.95%