Start by clarifying requirements (latency, update frequency, scale, consistency) and then walk through the end-to-end pipeline: ingestion, aggregation, storage, and delivery. Focus on the trade-offs between accuracy and latency, and explain how you would partition and scale each component.
Pro tip: Emphasize that the heatmap is an approximation and that you would use a sliding window with incremental updates to balance freshness and cost. Also, mention that you would monitor and adapt the update frequency based on driver density and client demand.
Ask about expected scale (number of drivers, pings per second, city size), latency requirements (e.g., <1s), update frequency, and consistency needs. Also clarify client types (mobile, web) and subscription patterns.
Choose a geospatial indexing scheme (e.g., geohash, S2, or H3) to partition the city into cells. Define the data model for driver locations and cell aggregates, considering time windows (e.g., sliding window of last N minutes).
Outline how driver pings are ingested (e.g., via Kafka), processed in a stream processor (e.g., Flink, Spark Streaming) to update cell counts, and how top-K per region is computed. Discuss windowing, watermarks, and handling late data.
Decide on a storage layer for aggregates (e.g., in-memory cache, Redis) and a pub/sub system (e.g., Kafka, Redis Pub/Sub) to push updates to WebSocket servers. Explain how clients subscribe to specific regions and receive updates.
Discuss horizontal scaling of ingestion, processing, and WebSocket servers. Explain how to handle failures (e.g., checkpointing, replication) and ensure exactly-once or at-least-once semantics. Mention monitoring and backpressure.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.