Skip to main content
BLUEPRINT #02Location & Geospatial

Design Google Maps & Distributed Routing Engine

Target AWS Architecture:S3ElastiCacheKinesisAPI Gateway
10-Stage Structure:1. Requirements→2. Sizing→3. Topology→4. Data Model→5. AWS Topology→6. Deep-Dive→7. Failures→8. SRE Playbooks

1. Problem Statement & Scope Clarification

System Mission

Design a planetary-scale digital mapping, shortest-path navigation, and real-time dynamic traffic routing platform (similar to Google Maps, Apple Maps, and Waze) capable of rendering high-definition vector map tiles globally, ingesting billions of live GPS telemetry pings, and calculating optimal driving routes across hundreds of millions of road segments in under 100 milliseconds.

Functional Requirements

  1. Vector Map Tile Rendering: Serve zoomable vector map tiles (Zoom 0 to 21) based on standard Slippy Map / Quadkey conventions with sub-20ms edge latency.
  2. Shortest-Path Driving Directions (GetDirections): Compute optimal routes considering turn restrictions, one-way streets, road hierarchies, and real-time traffic congestion.
  3. Accurate Estimated Time of Arrival (ETA): Predict travel durations incorporating live telemetry speed profiles and historical traffic patterns.
  4. Real-Time Dynamic Re-Routing: Push proactive detour alerts to in-flight drivers when accidents or unexpected congestion arise along their active route.
  5. Live GPS Map Matching: Snap noisy client GPS coordinates to physical road network segments using Hidden Markov Models (HMM).

Non-Functional Requirements (SLAs & SLOs)

  • Ultra-Low Latency:
    • Map Tile Rendering (Edge CDN): P99<20Β msP99 < 20\text{ ms}.
    • Long-Distance Cross-Country Routing: P99<100Β msP99 < 100\text{ ms}.
  • High Availability: 99.999%99.999\% uptime for navigation and directions.
  • Scale: Support 500,000,000Β DailyΒ ActiveΒ UsersΒ (DAU)500,000,000\text{ Daily Active Users (DAU)}, 50MΒ dailyΒ routeΒ calculations50\text{M daily route calculations}, and 1Β BillionΒ tileΒ requests/day1\text{ Billion tile requests/day}.

2. Capacity & Scale Estimation (Back-of-the-Envelope Math)

Road Network Graph Sizing

  • Global Intersections (Vertices VV): β‰ˆ100,000,000Β nodes\approx 100,000,000\text{ nodes} (100MΒ intersections100\text{M intersections}).
  • Global Road Segments (Edges EE): β‰ˆ300,000,000Β directedΒ edges\approx 300,000,000\text{ directed edges} (300MΒ segments300\text{M segments}).
  • Vertex Struct Size: node_id (8B), lat (4B float), lon (4B float), edges_offset (4B) β‰ˆ20Β bytes\approx 20\text{ bytes}.
  • Edge Struct Size: target_node (8B), distance_meters (4B), speed_limit (2B), live_weight (2B), flags (4B) β‰ˆ20Β bytes\approx 20\text{ bytes}.
  • Total Graph Memory Footprint: GraphΒ Memory=(100MΓ—20B)+(300MΓ—20B)=2.0Β GB+6.0Β GB=8.0Β GBΒ RAM\text{Graph Memory} = (100\text{M} \times 20\text{B}) + (300\text{M} \times 20\text{B}) = 2.0\text{ GB} + 6.0\text{ GB} = \mathbf{8.0\text{ GB RAM}}
  • Adding Contraction Hierarchy shortcut edges (+20%+20\%) yields β‰ˆ9.6Β GBΒ RAM\approx \mathbf{9.6\text{ GB RAM}}, allowing the entire planetary road graph to fit in the RAM / L3 cache of a single EC2 instance.

Telemetry Ingestion & Tile Traffic

  • Active Navigation Devices: 20,000,000Β activeΒ drivers20,000,000\text{ active drivers} emitting GPS pings every 5 seconds.
  • GPS Ingest : GPSΒ TelemetryΒ QPS=20,000,000Β drivers5Β seconds=4,000,000Β pings/sec\text{GPS Telemetry QPS} = \frac{20,000,000\text{ drivers}}{5\text{ seconds}} = \mathbf{4,000,000\text{ pings/sec}}
  • Map Tile Egress : Peak 50,000Β tileΒ requests/sec50,000\text{ tile requests/sec} (99.2%99.2\% cached at edge CDN).

3. High-Level Architecture & AWS Component Mapping

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

4. Shortest Path Graph Algorithms: Dijkstra vs Contraction Hierarchies

1. The Shortest-Path Complexity Evolution

AlgorithmQuery Time ComplexityAverage Nodes SettledLatency on Global GraphSuitability for Real-Time Navigation
Standard DijkstraO(E+Vlog⁑V)O(E + V \log V)β‰ˆ45,000,000Β nodes\approx 45,000,000\text{ nodes}2,000βˆ’5,000Β ms2,000 - 5,000\text{ ms}❌ Impossible for live UI
Bidirectional Aβˆ—A^* SearchO(E+Vlog⁑V)O(E + V \log V) with heuristicβ‰ˆ2,500,000Β nodes\approx 2,500,000\text{ nodes}300βˆ’800Β ms300 - 800\text{ ms}⚠️ Too slow for high concurrency
Contraction Hierarchies (CH)O(polylogΒ V)O(\text{polylog } V)β‰ˆ800βˆ’2,000Β nodes\approx 800 - 2,000\text{ nodes}<15Β ms< 15\text{ ms}Optimal (Industry Standard)

2. Contraction Hierarchies (CH) Mechanics

  1. Offline Preprocessing Phase: Order all road network nodes by importance (e.g. residential alleyways = lowest, interstate highways = highest). Iteratively "contract" nodes from lowest to highest, adding shortcut edges to preserve shortest distances between remaining neighbors.
  2. Bidirectional Upward Query Phase: Run forward Dijkstra from Origin and backward Dijkstra from Destination, strictly traversing edges that lead to nodes of higher rank. The search spaces meet at a peak node in <10Β ms< 10\text{ ms} after exploring only hundreds of nodes.
text
Query Space:
Origin (Residential) ---> Minor Arterial ---> Highway Peak Node <--- Highway <--- Destination
(Search explores ONLY upward hierarchy, ignoring millions of irrelevant side streets)

5. Live GPS Map-Matching with Hidden Markov Models (HMM)

Raw GPS coordinates have a 5βˆ’15Β meter5 - 15\text{ meter} error radius, frequently jumping onto parallel service roads or buildings. The engine snaps noisy points to physical road segments using Viterbi HMM Algorithms:

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

Part 2: Production Deep-Dive Locked1 Coin = 24 Hours

Unlock Complete Architecture & Production Runbooks

Your Balance:40 Coins

You have explored the free architectural preview (~45%). Spend 1 Coin to unlock the remaining 6 production deep-dive sections for a full 24 hours.

Sections Included in This 24-Hour Pass:
6. Detailed Request Flow & Navigation Lifecycle
7. Geospatial Routing Architecture Trade-Off Matrix
8. Failure Modes, Resiliency & Critical Edge Cases
9. Production Pitfalls & Anti-Patterns (The "Gotchas")
10. Production Runbook & Observability Guide
11. Interview Strategy & System Design Rubric
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure