Skip to main content

Design Google Maps

Difficulty: 🔴 Hard | Time: 45-60 min | Prerequisites: Graph algorithms, Geo-indexing, CDN
Design a large-scale navigation and mapping service that handles billions of queries daily, provides real-time traffic updates, and calculates optimal routes across the globe.

1. Requirements Clarification

Functional Requirements

Non-Functional Requirements

  • Latency: Route calculation < 200ms, map tiles < 50ms
  • Availability: 99.99% uptime
  • Scale: 1 billion daily active users, 10B+ daily API calls
  • Coverage: 200+ countries, 25+ million miles of roads

Capacity Estimation


2. High-Level Architecture


3. Core Components Deep Dive

3.1 Map Tile System

Maps are divided into tiles at different zoom levels using a quadtree structure.

Tile Addressing

Tile Caching Strategy

3.2 Road Graph Data Structure

The road network is stored as a weighted directed graph:

Graph Partitioning

The world’s road network is too large for a single machine. We use graph partitioning:
  • Partition by Geography: Each region (city, country) is a partition
  • Border Nodes: Connect partitions at highway entry/exit points
  • Contraction Hierarchies: Pre-compute shortcuts for faster long-distance routing

3.3 Routing Algorithm

For optimal routing, we use Contraction Hierarchies (CH) combined with A* search:

Route Alternatives

Users often want multiple route options:

3.4 Real-Time Traffic System

Traffic Calculation

3.5 ETA Prediction

ETA is not just distance/speed—it requires ML prediction:

To find nearby places efficiently, we use geospatial indexing:

Option 1: Geohash

Option 2: S2 Cells (Used by Google)

S2 geometry provides better coverage at poles and consistent cell sizes:

5. Data Pipeline

Map Update Pipeline


6. Scalability Considerations

Geographic Sharding

Each region runs independently with:
  • Local road graph replicas
  • Regional tile caches
  • Traffic data aggregation

Caching Strategy


7. Interview Tips

Common Follow-ups

  • Pre-download tiles for a region at multiple zoom levels
  • Compact road graph for the region (smaller than server version)
  • On-device routing with simplified algorithm
  • Sync updates when back online
  • GPS traces that don’t match existing roads
  • Satellite imagery + ML for road detection
  • User reports and driver feedback
  • Partner data from city governments
  • Real-time event ingestion from multiple sources
  • Immediate routing recalculation for affected areas
  • Push notifications to users on affected routes
  • Predictive modeling for incident duration

Key Trade-offs


8. Summary

Key Takeaways:
  1. Hierarchical graph with contraction hierarchies for fast routing
  2. Tile pyramid with aggressive CDN caching for map rendering
  3. S2 cells for efficient geospatial queries
  4. Real-time traffic from GPS probes + ML prediction
  5. Geographic sharding for global scale