System Design: Real-Time Driver Heatmap and Top-K Hottest Cells
Context
You are building a real-time heatmap for a ride-hailing platform to show driver density across a city. The city is partitioned into spatial grid cells (e.g., geohash/H3/S2). Driver apps send periodic location pings. The backend must aggregate these into live cell counts and stream updates to rider/ops clients over WebSockets. Additionally, the system must compute and publish the top-K hottest cells per region with low latency.
Assume city-scale load (hundreds of thousands of drivers, 1–5 pings/driver/min), sub-second to low-seconds end-to-end latency, and multi-region deployment.
Requirements
-
Partition city into fixed-size grid cells (e.g., geohash/H3/S2).
-
Ingest driver pings and compute active driver counts per cell in near real time.
-
Stream updates to clients over WebSockets (subscribe/unsubscribe flows).
-
Compute and publish top-K hottest cells per region with low latency.
-
Detail: data model, aggregation strategy (edge vs. server), update frequency, scalability, fault tolerance, and client subscription management.