Design a Continental Temperature Heatmap
Ingest continent-wide sensor readings for a fresh spatial heatmap and historical temperature queries.
Problem statement
Sensor devices are distributed across a continent and emit temperature readings. Design a system that renders a heatmap of the latest temperatures and lets users query historical data.
For this exercise, assume every device has a registered coordinate and emits a unique reading ID, device sequence, event time, and temperature; readings may arrive late or out of order.
The latest map must declare a freshness watermark, and historical queries support bounded regions, time ranges, and aggregation resolution. Cover ingestion, spatial bucketing, latest-state authority, time-series retention, map serving, late data, device health, and recovery.
Device firmware and meteorological forecasting are outside scope.
What to build
- Accept and deduplicate temperature readings while preserving event time and device order.
- Return spatially aggregated latest temperatures with freshness and coverage metadata.
- Return bounded historical series or aggregates for a region, interval, and resolution.
- Distinguish stale, missing, and suspect devices so absent data is not rendered as a valid temperature.
At scale
- For this exercise, assume ten million sensors emitting once every ten seconds, with short bursts after connectivity recovers.
- For this exercise, healthy readings should influence the latest heatmap within five seconds at p95 and map-tile reads should finish within 300 milliseconds at p95.
- For this exercise, retain raw readings for 30 days and hourly aggregates for five years.
- For this exercise, accepted readings and device registration must survive one availability-zone failure; a stale map must be labeled rather than silently presented as current.