Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Camera Heartbeat Health Dashboard

Design a heartbeat-ingestion and expiry system that maintains a fresh, trustworthy healthy-camera count for a fleet of one million devices.

Problem statement

For this exercise, assume a fleet of one million cameras normally emits one heartbeat every 20 seconds. A camera is healthy when the service has accepted its newest heartbeat within the latest 60 seconds; otherwise it is unhealthy.

Heartbeats contain a camera ID, unique heartbeat ID, device timestamp, and fleet metadata. Authenticated ingress durably assigns each accepted heartbeat an immutable server acceptance time and monotonic acceptance token before asynchronous buffering.

Only a greater acceptance token may advance latest state; its server acceptance time is authoritative for the 60-second deadline, so neither device-clock skew nor delayed processing of a lower-token event can extend a lease.

A previously unseen packet first reaching ingress later is intentionally new service-observed health evidence. Retries and post-ingress out-of-order delivery are expected and must not double count.

Authorized operators view a dashboard with the current healthy-camera count, data freshness, and an individual camera's last accepted heartbeat and status.

For this exercise, the dashboard may be a few seconds behind durable ingestion, raw heartbeats remain queryable for 24 hours, and ingestion or aggregation lag must be visible rather than silently reported as healthy.

Video transport, camera commands, firmware updates, alert delivery, and long-term telemetry analytics are out of scope.

What to build

  1. The service durably assigns acceptance order to identified camera heartbeats before buffering and advances latest-camera state only for a greater acceptance token, so duplicate or delayed post-ingress processing cannot renew health.
  2. Each camera transitions between healthy and unhealthy according to whether its latest accepted heartbeat is within the 60-second window.
  3. Authorized operators can view the current healthy-camera count with an explicit freshness or degraded-data indicator.
  4. Authorized operators can inspect one camera's current status and latest accepted heartbeat time.

At scale

  • The fleet contains 1 million cameras, each normally sending one heartbeat every 20 seconds, for 50,000 heartbeats per second on average and bursts up to 150,000 per second.
  • A camera becomes unhealthy when 60 seconds have elapsed since the server acceptance time of its greatest accepted token; duplicate and lower-token processing must not change that deadline.
  • Dashboard reads should complete within 1 second at p95, and a healthy-count change should be visible within 5 seconds of heartbeat acceptance or expiry under normal conditions.
  • Raw heartbeat events are retained for 24 hours for diagnosis, while current camera state and its version remain durable; an unavailable or lagging processing path must expose stale or partial status.