SDE & MLE Prep

Google Maps (Navigation & Routing)

Requirements: render the map at any zoom, find the fastest route between two points with live traffic, accurate ETA, turn-by-turn navigation with re-routing; ~1 B users, very read-heavy for tiles.

Estimates: the world at zoom level 21 is ~4.4 trillion 256×256 tiles (4²¹) — petabytes naive, but most tiles are ocean or empty land and compress to almost nothing; tiles are static → precompute and serve from a CDN. Active navigators send GPS points every few seconds (batched) → hundreds of thousands of location writes/s.

map tiles:   client --(zoom, x, y)--> CDN --miss--> tile store (S3)  <- offline tile/vector-tile pipeline
routing:     client -> routing svc -> routing tiles (road graph partitioned by region, cached in memory)
                                    -> live traffic layer (edge speeds) -> ETA model
location:    navigating clients --batched GPS--> Kafka -> map-matching -> traffic aggregation (per edge speed)
                                                                      -> ETA training data, re-route triggers

Deep dives

  • Tiles: precomputed per zoom level, addressed by zoom/x/y, cached by CDN; vector tiles (geometry, styled on the client) are smaller and allow rotation/3-D.
  • Routing at continent scale: plain Dijkstra/A* explores too much; production systems use Contraction Hierarchies or hierarchical routing: road graph partitioned into tiles with precomputed shortcuts between boundary nodes, so a query touches local roads near the endpoints and highways in between.
  • Live traffic: map-match GPS traces to road segments, aggregate speeds per edge per minute (stream processing), update edge weights; precomputed shortcuts must be refreshed (customizable CH).
  • ETA = route travel time from current speeds + ML correction (historical patterns by time of week, incidents) — see ETA Prediction in ML system design.
  • Re-routing: the client follows the route locally; the server pushes better routes when traffic changes significantly.