System design interview: design Google Maps
Designing a service like Google Maps means three systems that share a road graph: map tiles served from a CDN so the map draws quickly, a routing service that finds the best path and an ETA over a graph too large for plain Dijkstra, and a location pipeline that turns phones in moving cars into live traffic. In the interview, scope to tiles, routing and navigation, and show how live traffic feeds back into ETAs.
By Evin JohnPublished 7 min read
1. Clarify the requirements
"Design Google Maps" is too large for 45 minutes. Offer a scope and let the interviewer adjust it.
- Functional: show a pannable, zoomable map; get directions between two points for driving (walking and transit if time allows) with an ETA and alternatives; turn-by-turn navigation that reroutes on a missed turn or a jam.
- Non-functional: the map appears in about a second on a phone network; a route comes back within a second or two; ETAs are accurate enough that people trust them; navigation keeps working through brief signal loss.
- Out of scope unless asked: place search and reviews (covered in design a proximity service), Street View, building the map data itself from imagery, offline map downloads.
2. Estimate the scale
| Quantity | Assumption | Result |
|---|---|---|
| Map views | 300 million map opens a day, about 30 tiles each | about 104,000 tile requests a second on average, far more at peak; almost all served by the CDN |
| Tiles at one deep zoom level | zoom 18 has 4^18 tiles, about 69 billion; assume 10% contain anything but water or empty land | about 7 billion tiles at that level alone |
| Tile storage at that level | about 20 KB per non-empty tile | about 140 TB; vector tiles and one shared blank tile cut this sharply |
| Navigation sessions | 50 million a day, 25 minutes each | about 870,000 concurrent on average, about 2.6 million at a 3x peak |
| Location updates | one every 5 seconds while navigating | about 520,000 a second at peak |
| Route requests | assume 100 million a day, plus reroutes | about 1,200 a second on average plus reroutes, each a graph search |
Each subsystem has a different bottleneck: tiles are a bandwidth and caching problem, routing is a compute problem on a large graph, and traffic is a high-volume stream problem.
3. Define the API
GET /tiles/{style}/{z}/{x}/{y}.pbf -> vector tile (cacheable for days)
POST /v1/routes
{ origin: {lat, lng}, destination: {lat, lng}, mode: "drive", depart_at }
-> { routes: [ { polyline, distance_m, eta_s, steps: [...] } ], route_id }
POST /v1/navigation/{session_id}/location { lat, lng, speed, heading, ts }
-> { on_route: true, eta_s, reroute: null | { polyline, steps } }Tile URLs carry zoom, column and row. The phone computes which ones it needs from the viewport, so the server never decides what to send.
import math
def tile_for(lat, lng, zoom):
n = 2 ** zoom # tiles per side at this zoom
x = int((lng + 180.0) / 360.0 * n)
lat_r = math.radians(lat)
y = int((1 - math.asinh(math.tan(lat_r)) / math.pi) / 2 * n)
return zoom, min(x, n - 1), min(y, n - 1)
tile_for(10, 10, 1) # (1, 1, 0): north-east quarter at zoom 1
tile_for(51.5007, -0.1246, 15) # (15, 16372, 10897)4. Sketch the data model
| Data | Shape | Where it lives |
|---|---|---|
| Map tiles | Blob per (style, z, x, y) | Object storage behind a CDN |
| Road graph | Nodes (intersections) and directed edges (segments) with length, speed limit, turn restrictions | Partitioned into routing tiles, loaded into routing servers' memory |
| Live segment speeds | segment_id -> current speed, sample count, updated_at | In-memory store, refreshed every minute or so |
| Historical speeds | segment_id, hour of week -> typical speed | Batch-built table, loaded with the graph |
| Navigation sessions | session_id -> route, current position, last ETA | Short-lived key-value store with a TTL |
5. Routing on a graph this large
Plain Dijkstra explores outward in every direction until it reaches the destination. Across a continent that means millions of nodes per request, which is too slow at thousands of requests a second. The standard answers combine two ideas.
| Technique | Idea | Cost |
|---|---|---|
| A* | Steer the search toward the destination with a lower-bound estimate (straight-line distance at top speed) | Easy; helps, but still explores a lot on long trips |
| Hierarchical routing tiles | Split the graph into tiles at levels: local streets, arterials, highways; search detail only near the ends | Needs a build pipeline; slightly less than optimal on rare trips |
| Contraction hierarchies | Precompute shortcut edges that skip unimportant nodes, then search upward from both ends | Very fast queries; shortcuts must be rebuilt or patched when weights change |
| Bidirectional search | Search from both ends and stop when they meet | Roughly halves the explored area; combines with the others |
A clear interview answer: partition the graph into routing tiles at three levels, run bidirectional A* that uses local tiles near the origin and destination and only the highway level in the middle, and use live segment speeds as edge weights. Routing servers keep hot tiles in memory and load the rest on demand from storage, so no single machine needs the whole planet.
ETA. For each edge on the chosen path, predict travel time at the moment the car will reach it: blend the live speed (strong for the next few minutes) with the historical speed for that hour of the week (better for segments an hour away), and add time for turns and lights. Many teams then correct the total with a learned model trained on completed trips; mention it, but do not design the model.
6. The architecture
- Clients
- Phone app
- Web map
- Static
- CDN
- Tile storage
- Offline tile renderer
- Routing
- API gateway
- Routing service (graph tiles in memory)
- Historical speeds
- Live traffic
- Location ingestion
- Stream
- Traffic aggregation (map matching)
- Live speed store
- Navigation
- Navigation session service
- Push channel to phone
7. Deep dives
- Vector or raster tiles. Raster tiles are images: simple, but one copy per style and per screen density, and labels cannot rotate with the map. Vector tiles send geometry and let the phone draw it, so one tile serves every style and rotation, at the cost of rendering work on the device.
- Map matching. GPS points drift into the next street. Snap each trace to the most likely sequence of connected segments (a hidden Markov model is the textbook method) before computing speeds, or a highway looks jammed because some points landed on the service road.
- Privacy. Strip identities before aggregation, keep raw traces only briefly, and publish a segment's speed only when enough distinct phones contributed.
- Rerouting. The navigation service checks each position against the route. Off route by more than a threshold for a few updates: compute a new route from the current position. On route but a segment ahead slowed sharply: compute alternatives and offer one only if it saves meaningful time, so drivers are not bounced between roads.
- Updating the graph. New roads and closures arrive as edits. Rebuild affected routing tiles in a pipeline, version them, and roll new versions to routing servers gradually; a route must never mix two versions of one tile.
8. What breaks, and what you do about it
| Failure | Effect | Mitigation |
|---|---|---|
| Phone loses signal mid-route | No reroutes, no new ETA | Send the full route and steps up front; the app keeps guiding from GPS alone and resyncs on reconnect |
| Traffic pipeline stalls | Live speeds go stale | Fall back to historical speeds once data is older than a few minutes, and mark ETAs as less certain |
| Bad routing tile version | Routes through closed or missing roads | Validate with test routes before rollout; keep the previous version to roll back |
| Event traffic (a stadium emptying) | Sudden local slowdowns that history does not predict | Weight live data more when it strongly disagrees with history |
| CDN miss storm after a style change | Origin overload | Pre-warm popular zoom levels and cities; roll styles out gradually |
9. Trade-offs to discuss
- Precomputation or flexibility. Contraction hierarchies answer fastest but are costly to update as traffic changes; tile hierarchies with live weights adapt better. Many systems precompute structure and apply traffic as a separate layer.
- Freshness or stability. Rerouting on every speed change gives the theoretical best ETA and an annoying drive. A minimum saving before suggesting a switch is a product choice worth stating.
- Server or device work. Vector tiles and on-device routing for short trips cut server load and survive bad signal, at the cost of app size and battery.
10. How to talk through it in the interview
Fictional example
- Interviewer
- Why can't you just run Dijkstra on the road network?
- Candidate
- It is correct, but on a cross-country trip it explores a huge circle of nodes, and I need thousands of these a second. I would split the graph into tiles at three levels, search local tiles near both ends and only the highway level in the middle, and run it bidirectionally with A*. That keeps each search to a small slice of the graph.
- Interviewer
- Where do the edge weights come from?
- Candidate
- Live speeds from navigating phones, matched to segments and aggregated per minute, blended with the typical speed for that hour of the week. Near the car I trust live data; an hour down the route I lean on history.
- Split the prompt into tiles, routing and traffic in the first minute.
- Know one speed-up beyond A* and what it costs to maintain.
- Close the loop: phones produce traffic data that changes the routes they receive.
Practicing this design with Natively
A maps prompt has more parts than most, so the risk is spending twenty minutes on tiles. Rehearse with someone playing the interviewer while Natively transcribes the call; afterwards the transcript shows where the time went. In the moment you can ask it to brainstorm approaches to routing or to draw the traffic loop as a diagram, and a screenshot of your own sketch can be read and critiqued.
Questions people ask
How do you design Google Maps in a system design interview?
Scope it to three parts: map tiles served from a CDN, a routing service that finds paths and ETAs on a partitioned road graph, and a location pipeline that turns navigating phones into live traffic. Spend most of the time on routing and on how traffic data feeds back into ETAs.
Why not use Dijkstra's algorithm for map routing?
Dijkstra is correct but explores outward in every direction, which is far too much work on a continental road graph at thousands of requests a second. Interview answers add A*, bidirectional search and a hierarchy, such as routing tiles by road class or contraction hierarchies, so each search touches a small part of the graph.
How is ETA calculated in a maps system?
Sum the predicted travel time of each road segment on the route at the time the car will reach it. Near segments use live speeds from phones, distant ones lean on historical speeds for that hour of the week, and turn and signal delays are added. A learned correction on completed trips is a common refinement.
What are map tiles?
The map is cut into square tiles for each zoom level, where zoom z has 4 to the power z tiles. Phones request the tiles that cover the screen by zoom, column and row, and a CDN serves them as static files. Vector tiles send geometry and let the device draw it.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
