Design a Camera Health Dashboard
VerkadaSoftware Engineer · Technical ScreenLast updated
This problem tests the ability to design a high-throughput ingestion system and a real-time state management strategy for time-sensitive IoT heartbeats.
System Design: Camera Health Dashboard
Design a backend system that monitors the health status of one million security cameras. Each camera sends a 'heartbeat' packet (a simple JSON payload containing camera_id and timestamp) every 10 seconds. The dashboard must display the real-time status of all cameras, specifically highlighting those that have not reported a heartbeat in the last 60 seconds as 'offline'.
Functional Requirements
- Ingest heartbeat events from 1,000,000 cameras.
- Expose an API endpoint
GET /cameras/offlinethat returns the IDs of all cameras that have not checked in within the last 60 seconds.
Non-Functional Requirements
- The system must handle 100,000 heartbeats per second (based on the provided frequency).
- The offline status should be updated with no more than a few seconds of latency.
- The system should be resilient to transient network spikes.
Design Deliverables
- Describe your data ingestion pipeline and storage strategy.
- Explain how you determine the 'offline' set efficiently without scanning all one million records every time the API is called.
- Discuss how you handle data expiration and potential bottlenecks at scale.
Hints
Hint 1
Consider using an in-memory data structure like a Redis Sorted Set where the score is the timestamp of the last heartbeat.
Hint 2
Decide whether a push-based model (writing to a database) or a pull-based model (active polling) is better suited for the 60-second window requirement.
Hint 3
Evaluate if you need a persistent database for the raw heartbeats, or if the dashboard state can live primarily in a fast, distributed cache.
Follow-up questions
- How would you modify your design if you needed to provide a 24-hour historical uptime percentage for each camera?
- If the heartbeat frequency increases from 10 seconds to 1 second, how does your ingestion architecture change to prevent system overload?
- How would you handle a situation where a massive group of cameras go offline simultaneously (e.g., a regional power outage) to prevent a thundering herd problem on your dashboard?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.