Design real-time driver heatmap system
System Design: Real-Time Driver Heatmap and Top-K Hottest Cells
Context
Design a real-time heatmap system for a ride-hailing platform to visualize driver density across a city. The city is logically partitioned into spatial grid cells using a system like Geohash, H3, or S2. Driver applications periodically send location pings to the backend. The core functionality involves aggregating these pings into live active driver counts per cell and streaming these updates to rider and operations clients via WebSockets. Additionally, the system must identify and publish the top-K hottest cells (those with the highest driver density) for various regions with low latency.
The system must handle city-scale load, supporting hundreds of thousands of drivers, each sending 1 to 5 location pings per minute. End-to-end latency, from driver ping to client update, should be sub-second to low-seconds. The architecture should also support multi-region deployment.
Requirements
- Partition the city into fixed-size grid cells (e.g., using Geohash, H3, or S2).
- Ingest driver location pings and compute active driver counts per cell in near real-time.
- Stream real-time updates to subscribed clients over WebSockets, including managing subscribe/unsubscribe flows.
- Compute and publish the top-K hottest cells per region with low latency.
- The design should detail the data model, aggregation strategy (considering edge vs. server-side processing), update frequency, scalability mechanisms, fault tolerance, and client subscription management.
AI interview prep
Core dilemma
Balancing extreme write throughput from driver pings with low-latency, real-time aggregation, consistent data distribution via WebSockets, and efficient Top-K analytical queries across a distributed, multi-region architecture. Defining and maintaining 'active driver' state in a high-churn environment adds significant complexity.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design real-time driver heatmap system
System Design: Real-Time Driver Heatmap and Top-K Hottest Cells
Context
Design a real-time heatmap system for a ride-hailing platform to visualize driver density across a city. The city is logically partitioned into spatial grid cells using a system like Geohash, H3, or S2. Driver applications periodically send location pings to the backend. The core functionality involves aggregating these pings into live active driver counts per cell and streaming these updates to rider and operations clients via WebSockets. Additionally, the system must identify and publish the top-K hottest cells (those with the highest driver density) for various regions with low latency.
The system must handle city-scale load, supporting hundreds of thousands of drivers, each sending 1 to 5 location pings per minute. End-to-end latency, from driver ping to client update, should be sub-second to low-seconds. The architecture should also support multi-region deployment.
Requirements
- Partition the city into fixed-size grid cells (e.g., using Geohash, H3, or S2).
- Ingest driver location pings and compute active driver counts per cell in near real-time.
- Stream real-time updates to subscribed clients over WebSockets, including managing subscribe/unsubscribe flows.
- Compute and publish the top-K hottest cells per region with low latency.
- The design should detail the data model, aggregation strategy (considering edge vs. server-side processing), update frequency, scalability mechanisms, fault tolerance, and client subscription management.