KatInterview

Design a Fleet Health Monitoring System for Edge Devices

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsstreaming

Last updated

Architect a scalable real-time monitoring system to track the online/offline status of 10 million connected edge devices with low latency and high availability.

Architect a monitoring infrastructure for a fleet of 10 million IoT security cameras. The system must continuously track device status and provide real-time dashboard metrics showing the exact total count of healthy and unhealthy cameras across the network.

Operating Environment & Requirements

  • Fleet Size: 10,000,000 registered cameras.
  • Heartbeat Rate: Each camera emits a small ping (payload containing camera_id, timestamp, firmware_ver) once every 60 seconds.
  • Health Definition: A device is marked healthy if the system has ingested at least one heartbeat from it within the last 120 seconds (2 minutes). If 120 seconds elapse without a heartbeat, the device transitions to unhealthy.
  • Dashboard Latency: Global health metrics should be updated within 5 to 10 seconds of real-world state changes.
  • Data Retention: The dashboard only requires live global/aggregated status metrics. Storing full historical time-series raw logs is out of scope.

Core Challenges to Address

  1. Ingestion Layer: Efficiently receiving ~167,000 requests/sec under steady state, while handling "reconnect storms" (e.g., after regional internet outages) where traffic spikes to 500,000+ requests/sec.
  2. State Management: Storing and updating per-camera operational status efficiently without performing full 10M row table scans every few seconds.
  3. Expiration Detection: Detecting when a camera stops sending heartbeats and transitioning its status to unhealthy in real time.
  4. Data Integrity: Handling duplicate pings, out-of-order network packets, and late-arriving messages without skewing the aggregate counters.
  5. System Resiliency: Recovering state after node failures and ensuring counter accuracy.

Hints

Hint 1

Avoid periodic full database scans across all 10 million records; design state updates around event-driven transitions.

Hint 2

Partition incoming device updates by `camera_id` so all events for a specific device are processed sequentially on the same worker node.

Hint 3

Use time-bucketed data structures or a timer wheel mechanism to track offline timeouts efficiently without polling every device record.