Frontend Labs
⋯

51. Walkthrough: Design Google Maps Routing & Navigation

The prompt. "Design Google Maps" or "Design the directions / navigation service." Scope it immediately. Maps is many systems: map tiles, places search/geocoding, routing/ETA, and live traffic. Interviewers usually want routing plus traffic, with tiles as a brief mention.

Step 0 — Clarify the business goal

🎤 Candidate: For navigation, the outcomes are ETA accuracy and route quality, which drive trust and daily use. For the business, they also feed local ads and ride-hailing and delivery partners through APIs. Shall I focus on driving directions with live traffic, plus how tiles are served?

🧑‍💼 Interviewer: Yes. Driving routes with live traffic, global scale.

Step 1–2 — Requirements

Functional Non-functional
Route A→B (driving), alternatives, ETA Route computation p99 < 500 ms for continental distances
Live traffic in ETAs; reroute during navigation Road graph: ~hundreds of millions of nodes/edges worldwide
Turn-by-turn navigation Traffic updates reflected in ETAs within ~1–2 min
Map display (tiles) Tiles served from CDN; very high read volume

Step 3 — Estimates

Road graph (world): order of 10^8-10^9 nodes/edges → tens of GB in compact form → fits in RAM per server
  → replicate the whole graph per routing server; no cross-server graph traversal
Plain Dijkstra on a continental graph explores millions of nodes → seconds → too slow
Routing QPS: e.g. 100M route requests/day + reroutes → ~2-5k QPS avg, more at commute peaks
Traffic probes: tens of millions of phones sending speed samples → aggregated per road segment per minute

Step 5 — High-level architecture

 Map data (sources, edits, imagery-derived) ─▶ map build pipeline ─▶ versioned road graph
     ├─▶ preprocessing: partition graph into cells (multi-level) / build contraction hierarchy
     └─▶ vector tile generation per zoom level ─▶ object store ─▶ CDN (tiles are static, cacheable)
 Phones (opt-in) ─location/speed probes─▶ ingestion ─▶ map matching (snap to road segments)
     ─▶ streaming aggregation: speed per segment per minute (anonymized, k-anonymity thresholds)
     ─▶ traffic metric publisher (every ~1 min) ─▶ routing servers (update edge weights)
 Client ─route request─▶ Routing front end ─▶ routing server (graph + current metric in RAM)
     ─▶ fast query on preprocessed graph ─▶ ETA model (ML correction using history + live)
     ─▶ alternatives ─▶ response (polyline + steps + ETA)
 Navigation session: client follows route; server (or client) re-checks periodically and on deviation

Step 6 — Deep dives

  1. Why preprocessing: Contraction Hierarchies (CH) add "shortcut" edges so queries explore only a tiny upward search from each end (milliseconds instead of seconds). But CH preprocessing depends on the edge weights, so live traffic would require re-contracting. Customizable Route Planning (CRP), from Microsoft Research and used in Bing Maps, separates a metric-independent partition (done once) from a fast customization step that applies new weights (traffic) in seconds. This is the key insight to state: separate topology preprocessing from metric updates. OSRM (open source) implements both CH and a multi-level Dijkstra (MLD) variant.
  2. Traffic pipeline: map matching of noisy GPS (§36), outlier removal, per-segment speed aggregation, a minimum number of contributors per segment for privacy, and fusion with historical speed profiles (by time of week) where live data is sparse.
  3. ETA: a graph route gives a base travel time. ML corrects it with learned effects (turns, signals, time of day). DeepMind and Google described graph neural networks improving ETA accuracy in Google Maps (2020).
  4. Tiles: vector tiles per zoom level (z0–z20) mean the client renders styling, so one tile set serves many themes. They're immutable per map version, so they're cacheable forever at the CDN with versioned URLs.

Step 7 — Failure modes & corner cases

Issue Response
Rerouting herds: an incident causes everyone to be sent down the same side street, which then jams Route diversity / load-aware assignment for large flows; predicted (not just current) traffic
Turn restrictions, time-dependent rules (no left turn 7–9 am), toll and ferry schedules Model them in the graph (edge-based or turn tables); time-dependent edge weights
Map data errors (a closed road still routable) Fast correction pipeline from user reports, with hot-patch overlays on the graph between builds
Graph version rollout Atomic switch per server; routes include the map version, so navigation sessions stay consistent
Privacy of location traces Aggregate, minimum contributor counts, trim trip endpoints, retention limits
Region or partition boundaries Cross-border routes need the full graph or cross-cell stitching; replicating the whole graph per server avoids this

🌍 Real-world references

  • Delling, Goldberg, Pajor, Werneck, "Customizable Route Planning" (Microsoft Research; journal version 2015, earlier conference papers), deployed in Bing Maps.
  • Geisberger et al., "Contraction Hierarchies" (2008), plus the OSRM open-source routing engine.
  • DeepMind & Google Maps, "Traffic prediction with advanced Graph Neural Networks" (2020).
  • Uber and Lyft engineering blogs on map matching and ETA (§36).

Generated from real-life-system-design-guide.md · 8 Oct 2026 16:36