NEW: ML Mock & Coaching now available

Questions

Google Maps

GoogleAppleUber

Design Google Maps - This system design covers route planning with graph partitioning, real-time traffic integration, shortest path algorithms at scale, and turn-by-turn navigation.

55 min read

Challenge

Think Beyond the Happy Path

Real production systems aren't just about finding shortest paths — they're about graph-scale optimization, real-time data integration, and low-latency computation.

Before diving into the material, take a moment to ask yourself:

  • Do you know why standard Dijkstra's or A* algorithms can't be directly applied to a road network with billions of edges?
  • Do you know how to partition a massive graph into manageable "cells" for parallel processing?
  • Do you know how to incorporate real-time traffic conditions into route planning without recomputing the entire graph?
  • Do you know how to dynamically re-route users when traffic conditions change mid-journey?

You don't need to answer all of these right away. A Senior/Staff+ Engineer doesn't stop at basic functionality — they anticipate edge cases, design for resilience, and push for production-grade reliability.

But great systems start with great questions. What would you ask next?

Problem Statement

Design a navigation system like Google Maps that allows users to search for locations, plan optimal routes between two points, and receive turn-by-turn navigation instructions. The system should:

  1. Support location search with address resolution.
  2. Compute optimal routes considering real-time traffic conditions.
  3. Provide real-time navigation with dynamic re-routing. And the scale is billions of road segments with sub-second route computation.
What makes Google Maps unique compared to Yelp and Uber?

Each geo-based system has its own unique technical challenges:

  • Design Yelp: Efficient proximity search — finding businesses based on location using spatial indexing (QuadTree, GeoHash).
  • Design Uber: Handling massive scale real-time location updates from drivers and ensuring consistent driver-rider matching.
  • Design Google Maps faces its own unique challenges:
    • Computing optimal routes with low latency on an extremely large road network graph (billions of vertices and edges)
    • Calculating accurate ETAs by combining static graph data with real-time traffic conditions
    • Dynamic re-routing when conditions change during navigation
Understanding Shortest Path Algorithms

In a system design interview for Google Maps, the focus isn't on explaining algorithms like Dijkstra's, A*, or Bellman-Ford. While knowing these algorithms is valuable, the real challenge is how to apply shortest path algorithms efficiently to an enormous road network with:

  • Billions of road segments (edges)
  • Millions of intersections (vertices)
  • Real-time traffic conditions
  • Sub-second response requirements
Algorithm Comparison
NameDescription
Dijkstra'sO((V + E) log V) | Best for: Guaranteed shortest path | Limitation: Explores all directions equally; slow for large graphs.
A*O(E) with good heuristic | Best for: Directed search toward goal | Limitation: Requires admissible heuristic; still slow at scale.
Bellman-FordO(V × E) | Best for: Handles negative weights | Limitation: Too slow for real-time routing.
Contraction HierarchiesO(log V) query time | Best for: Pre-processed static graphs | Limitation: Expensive preprocessing; hard with dynamic weights.

The key is to discuss system-level optimizations and techniques that make these algorithms practical at scale, such as:

  • Graph partitioning into cells/tiles
  • Hierarchical routing (cell-level then road-level)
  • Pre-computation and caching of common routes
  • Parallel processing across graph partitions

Functional Requirements

FR1 – Location Search

Users can search for locations and receive corresponding physical addresses (geocoding and reverse geocoding).

FR2 – Route Planning

Users can request and receive optimal routes between two locations, considering distance, time, and traffic conditions.

FR3 – Navigation

Users can obtain turn-by-turn navigation instructions for their selected route, with dynamic re-routing when conditions change.

Non-Functional Requirements

NFR1 – Low Latency

The system should recommend routes and calculate ETAs with low latency (p99 < 3 seconds).

NFR2 – Accuracy

The routes and ETAs must be accurate. Specifically:

  • Routes should be "traversable" (no invalid road segments or turns).
  • ETAs should be within ±10% of actual travel time for 90% of trips.

NFR3 – High Availability

The system should maintain 99.99% uptime.

NFR4 – Scalability

The system should scale horizontally to support millions of concurrent users, with the ability to handle increased traffic during peak periods.

Requirement Summary

Functional Requirements (FRs)
NameDescription
1. Location SearchSearch locations and receive physical addresses (geocoding).
2. Route PlanningCompute optimal routes between two locations with traffic awareness.
3. NavigationTurn-by-turn instructions with dynamic re-routing.
Non-Functional Requirements (NFRs)
NameDescription
1. Low LatencyRoute computation p99 < 3 seconds.
2. AccuracyTraversable routes; ETAs within ±10% for 90% of trips.
3. High Availability99.99% uptime.
4. ScalabilitySupport millions of concurrent users with peak handling.

Core Entities

To tie these requirements together into a coherent architecture, we begin with the foundational data structures that model the road network.

Cell — Geographic Partition

A Cell represents a bounded geographical area containing a manageable portion of the road network. Cells enable:

  • Parallel processing of route computation
  • Efficient memory management
  • Hierarchical routing (cell-level then road-level)
Cell Table
FieldTypeKeyDescription
cell_idBIGINTPKUnique identifier for the cell.
coordinatesPOLYGONNOT NULLGeographic boundaries (NW, NE, SW, SE corners).
adjacent_cellsBIGINT[]NOT NULLIDs of neighboring cells.
exit_pointsJSONBNOT NULLBorder crossing points with adjacent cells.
zoom_levelINTNOT NULLHierarchical level (higher = more detail).

Road Network — Graph Within a Cell

The Road Network contains the detailed graph structure within a cell, including all road segments and intersections.

RoadNetwork Table
FieldTypeKeyDescription
cell_idBIGINTFK → cells(cell_id)Reference to containing cell.
graphGRAPHNOT NULLDetailed road network (nodes + edges).
exit_pointsNODE[]NOT NULLBorder crossing points with adjacent cells.
precomputed_distancesJSONBNULLABLECached distances between exit points.

Road — Individual Road Segment

A Road represents a single road segment (edge) in the graph, connecting two nodes (intersections or waypoints).

Road Table
FieldTypeKeyDescription
road_idBIGINTPKUnique road segment identifier.
cell_idBIGINTFK → cells(cell_id)Containing cell.
source_nodeNODENOT NULLStarting intersection/waypoint.
target_nodeNODENOT NULLEnding intersection/waypoint.
distance_metersINTNOT NULLPhysical length of road segment.
base_travel_timeINTNOT NULLTravel time at speed limit (seconds).
speed_limitINTNOT NULLSpeed limit in km/h.
road_typeENUMNOT NULLhighway/arterial/residential/toll.
traffic_levelENUMNOT NULLnone/light/medium/heavy.
traffic_multiplierFLOATNOT NULL DEFAULT 1.0Current traffic weight.

Sign in to continue reading

"Google Maps" requires a free account to access.

Sign in to continue