Skip to content

Design Google Maps

A system design interview walkthrough for Google Maps, covering map tiles and CDN caching, routing on a road graph, contraction hierarchies and live traffic.

Advanced24 minUpdated 2 December 2026

Before this: Spatial Indexing (QuadTrees & GeoHashing), Content Delivery Network (CDN)

"Design Google Maps" is really three questions in a trench coat: draw the map, find a route, and tell me when I will arrive. Each has a different workload, a different data structure and a different failure mode.

The interviewer is checking whether you can split a vague product into independent subsystems, and whether you know that the obvious algorithm for routing, Dijkstra's, does not survive contact with a continent. Candidates who spend 40 minutes on tile caching and never mention the road graph, or the reverse, have missed half the question.

Pick the order: tiles first (simple, high volume), routing second (the hard algorithmic part), traffic third (where the two collide). The spatial indexing and CDN lessons cover the background.

Clarify the requirements

Functional requirements:

  1. Display a map the user can pan and zoom.
  2. Search for a place and move the map to it.
  3. Compute a route between two points for driving, walking or transit.
  4. Show an estimated time of arrival that reflects current traffic.
  5. Reroute during navigation when the user leaves the route or traffic changes.

Out of scope, said aloud: street-level imagery, business reviews (that is Yelp), offline maps, transit timetable ingestion, how the base map data is collected.

Non-functional requirements: these decide the design.

  • Map tiles must load fast: a pan that waits a second for the next tile feels broken, so tiles come from a CDN edge.
  • Routes in about a second: a continental graph has hundreds of millions of intersections, so the algorithm matters more than the hardware.
  • Traffic is fresh, base maps are not. The road network changes over days or weeks, while congestion changes over minutes. The two data sets need different pipelines.
  • Degrade, don't fail: if live traffic is down, show a route with typical travel times rather than no route.

Estimate the scale

Assume 50 million daily active users. Each opens the map about 4 times a day and each session loads about 30 tiles as the user pans and zooms, so 120 tile requests per user per day. Assume one route request per user per day.

Tile reads: 50M × 120 = 6 billion a day ÷ 86,400 ≈ 69,000 per second, and about 208,000 per second at peak (3×).

CDN effect: tiles are static and shared, so a CDN hit rate of 95% leaves 5% going to the origin: 69,000 × 0.05 ≈ 3,500 origin requests per second on average, about 10,400 at peak.

Route requests: 50M × 1 ÷ 86,400 ≈ 580 per second, 1,700 at peak. If each route search costs 10 ms of CPU, that is about 6 cores on average and 17 at peak, which is small, as long as the algorithm keeps a search to 10 ms (more on that below).

Tile storage: a tile pyramid has 4 tiles at each zoom level for every tile one level up. Counting from zoom 0 to zoom 15, the total is (4¹⁶ − 1) ÷ 3 ≈ 1.43 billion tiles. At about 15 KB each that is roughly 21 TB, before you drop empty ocean tiles, which are identical and deduplicated.

Bandwidth: at 15 KB, peak tile traffic is 208,000 × 15 KB ≈ 3.1 GB per second, which is why the CDN carries it, not your origin.

"Tile traffic is huge but almost entirely cache hits, so the origin only sees about 3,500 requests a second. The design problem is not serving tiles, it is routing: 580 searches a second is tiny, if and only if each search is cheap. That points to preprocessing the road graph."

The capacity estimator reproduces the request rates. Its storage figure (9 TB) is what you would keep if you logged every route request at 500 bytes for a year.

API and data model

GET /v1/tiles/{z}/{x}/{y}                      -> tile (image or vector data), cacheable
GET /v1/search?q=&near=lat,lng                  -> places
GET /v1/route?from=&to=&mode=driving            -> { legs[], distance, eta, polyline }
POST /v1/navigation/{id}/position   { lat, lng, heading }  -> reroute if needed
tile store:  key = "{style}/{z}/{x}/{y}"  -> bytes   (object store)
road graph:  node (id, lat, lng)   edge (from, to, length_m, speed_class, base_time_s)
traffic:     edge_id -> { current_speed, updated_at }   (in memory, short TTL)

The tile key is the whole API: the URL is the cache key. Because a tile is addressed by zoom, x and y, a CDN can cache it with no application logic, and the client can compute which tiles it needs from its own viewport.

High-level design

The slice worth running is the tile path, since it carries the volume: clients, a CDN, a tile service and a tile store.

Map tile requests are served from CDN edge caches, and only misses reach the tile service and the tile store that holds the pre-rendered tiles.clientstile cdntile servicetile store
Map tile requests are served from CDN edge caches, and only misses reach the tile service and the tile store that holds the pre-rendered tiles.
  • Clients request tiles by zoom, x and y through a CDN.
  • On a miss, the tile service reads the pre-rendered tile from the tile store.
Describe this diagram

Components

  • clients (Client)
  • tile cdn (Content delivery network)
  • tile service (Service)
  • tile store (Object storage (S3))

Connections

  • clients sends to tile cdn
  • tile cdn sends to tile service
  • tile service sends to tile store

Run it, then try shrinking the CDN's effect by raising the load, and watch the tile service become the part that saturates.

The tile path: the client turns its viewport and zoom level into a list of (z, x, y) tiles, fetches them in parallel from the CDN, and stitches them on screen. A miss falls to the tile service, which reads the tile from object storage and returns it with a long cache lifetime.

The route path: a separate routing service holds the road graph in memory, partitioned by region. It receives two points, snaps each to the nearest road node, runs the search and returns a polyline plus an ETA. Search and tiles share nothing except the map version they were built from.

The interesting problem: routing on a continent-size graph

A road network is a graph: intersections are nodes, road segments are weighted edges. Shortest path is textbook, until the graph has hundreds of millions of nodes and you must answer in a second.

Approach A: Dijkstra from the source

Expand outward from the start, always settling the nearest unsettled node, until you reach the destination.

Good: simple, exact and handles changing weights trivially, since there is no precomputation.

Bad: it explores a disc around the start. A cross-country route settles most of a country's nodes before it reaches the target, which is millions of nodes and seconds of CPU per query. At 580 routes a second it does not scale.

Approach B: A* with a straight-line heuristic

Bias the search toward the destination using straight-line distance divided by the maximum speed as the estimate of remaining cost.

Good: explores an ellipse toward the goal instead of a full disc, and needs no precomputation, so it still works with live weights.

Bad: a few times faster, not a few thousand times. Long routes still settle huge numbers of nodes, because roads do not run straight.

Approach C: precompute shortcuts with a hierarchy

Rank nodes by importance and contract the unimportant ones: removing a node and adding a shortcut edge between its neighbors that preserves shortest-path distances. After contracting most of the graph, motorway-like edges remain at the top of the hierarchy. A query then searches upward from both the source and the destination and meets in the middle, visiting a few hundred nodes instead of millions. This is the idea behind contraction hierarchies.

Good: query time drops from seconds to well under a millisecond or a few milliseconds in published results on continental road networks.

Bad: preprocessing takes minutes to hours and assumes edge weights do not change. A new traffic jam invalidates shortcuts that were computed with the old weights.

The recommended answer is C for the static skeleton, with traffic handled separately (next section). Say why: routing is 580 queries a second against a graph that changes slowly, which is exactly the shape where paying for preprocessing once and answering every query cheaply wins. Partition the graph by region, keep each partition in memory on a routing node, and let a long route stitch together partitions through a small high-level graph of the border nodes.

Conceptual diagramSourceSearch up the hierarchyDestinationSearch up from the destinationMeet at a high-rank nodeUnpack shortcuts into road segmentsRoute polyline and ETA
Diagram, as text
  • Source leads to Search up the hierarchy
  • Destination leads to Search up from the destination
  • Search up the hierarchy leads to Meet at a high-rank node
  • Search up from the destination leads to Meet at a high-rank node
  • Meet at a high-rank node leads to Unpack shortcuts into road segments
  • Unpack shortcuts into road segments leads to Route polyline and ETA

The second decision: live traffic against precomputed routes

A hierarchy is built on fixed edge weights, but a crash on a motorway changes them within minutes. You have three choices, and a good answer names the trade-off.

  • Rebuild periodically: recompute weights every few minutes and rebuild affected partitions. Simple, but the hierarchy lags reality.
  • Customize instead of rebuild: keep the graph's structure and ranking fixed, and recompute only the shortcut weights when traffic changes. This is far cheaper than a full rebuild, and routing remains fast.
  • Re-check the top candidates: use the static hierarchy to find a few good routes, then re-evaluate their travel times with current speeds and pick the best.

Where does traffic data come from? Anonymous position reports from devices on the road: each report gives a speed on a road segment, an aggregation job (a stream processor) averages the reports per segment over a window of a minute or two, and writes the result to an in-memory store keyed by edge. The routing service reads current speeds from there, falling back to the typical speed for that hour of the week when a road has too few reports. Mention privacy: aggregate and drop identifiers, and require a minimum number of reports before a segment's speed is used.

The ETA is the sum over the route's edges of length ÷ current_speed, plus an adjustment for the time it will take to reach each later edge, since traffic at the start differs from traffic 40 minutes ahead. Use predicted speeds for later edges when you have them.

Bottlenecks and failures

Hot tiles. A big event or a viral place sends many users to the same few tiles. They are static, so the CDN absorbs it. Set a long TTL and version the tile URL when the base map changes, so you invalidate by deploying a new version path, not by purging.

Cold tiles at deep zoom. Zoom-18 tiles of rural areas are almost never requested. Pre-render the popular levels (say 0 to 15) and generate the deeper ones on demand, caching the result.

The routing node down. Partitions are replicated, so a failed node loses a copy, not a region. Route to another replica, and keep enough spare capacity that losing one replica does not overload the other.

Traffic feed down or delayed. Fall back to historical speeds and tell the user the ETA is "typical" and not live. A wrong live ETA is worse than an honestly labeled typical one.

A map update during navigation. A user mid-route must not see the road network swap underneath them. Pin a navigation session to a map version, and move new sessions to the new one.

Reroute storms. When a big road closes, every navigating user on it needs a new route at once. Rate-limit reroute checks per session, route in batches and prefer an increment of the current route over a full search when the user is still near it.

Trade-offs to name aloud

  • Precomputed hierarchy over live Dijkstra: fast queries and an expensive build, in exchange for weights that must be customized when traffic changes.
  • Pre-render shallow zooms, render deep zooms on demand: most of the 21 TB is never requested, so you pay for it only when someone asks.
  • Vector over raster tiles: vector tiles are smaller and re-style on the client, but cost client CPU. Raster is simple and works everywhere.
  • Typical speeds as the fallback: a less accurate ETA, in exchange for always returning a route.

What interviewers listen for

  • A working answer: tile pyramid by zoom, x, y served from a CDN, a road graph with a shortest-path search, and a separate traffic source.
  • A strong answer: estimates the tile traffic and shows the CDN removes most of it, explains why Dijkstra over a whole country is too slow, and names a hierarchy or similar preprocessing as the fix.
  • A standout answer: reconciles precomputation with live traffic through customization or candidate re-checking, aggregates traffic privately with a minimum report count, pins navigation sessions to a map version and falls back to typical speeds.

Check your understanding

Common mistakes

Designing only the tile server. Tiles are the easy, cache-friendly part. If routing never appears in your answer you skipped the hard half.

Running Dijkstra on the whole graph. It is correct and far too slow at this size. Say that you preprocess.

Forgetting that precomputation freezes weights. A hierarchy answers fast and goes stale with traffic. Name the customization step before the interviewer asks.

Purging the CDN to update the map. Version the tile path instead, so old and new maps coexist and caches expire naturally.

Sending raw locations to the traffic pipeline. Aggregate per road segment, drop identifiers and require a minimum number of reports. Otherwise the traffic layer is a tracking system.

Treating ETA as distance divided by one speed. Speeds differ per road segment and change along the trip.

Practice

After a city-wide event, tile requests for one district jump 20x, and the tile service starts timing out. Walk through what you check and change.

Write your own answer first, on paper or in a note. Then compare.

Show a hint

Tiles are static, so ask first why they are reaching the service at all.

Show a strong answer

Check the CDN hit rate first. A 20x jump on static tiles should be absorbed at the edge. If the hit rate fell, find out why: a deploy that changed the tile URL version, a TTL that expired for the whole district at once, or a cache key that includes a query parameter such as a timestamp.

Fix the stampede. If thousands of users miss the same tile at once, collapse them: have the CDN's origin shield or the tile service coalesce requests so only one fetch goes to storage, and serve the rest from that response.

Add headroom where it is cheap. Raise the TTL for that district, warm the tiles in the CDN ahead of the event, and scale the tile service out, since it is stateless.

The pattern worth keeping: for static content, a load spike that reaches the origin is a symptom of a cache problem, so fix the cache before you scale the origin.

Users complain that ETAs are 10 minutes too optimistic during rush hour. How do you diagnose and fix it?

Write your own answer first, on paper or in a note. Then compare.

Show a hint

Separate the data (speeds) from the computation (how the ETA is summed).

Show a strong answer

Check the traffic data. Are current speeds missing on the affected roads? If too few reports arrive, the service falls back to free-flow speeds, which are optimistic. Add a report count to the data and alert when a major road has none.

Check how the ETA is computed. Summing current speeds at the start of the trip assumes today's jam will have cleared or stayed the same for the whole route. Use predicted speeds for later edges, built from the typical speed for that hour of the week and adjusted by today's deviation.

Measure against reality. Log the ETA given at route start and the actual trip duration for completed navigations, and track the error by hour and road type. That tells you if the fix worked.

The pattern worth keeping: a prediction is only as good as its worst input, so log predictions against outcomes and let the error data, not intuition, point at the faulty input.

Key takeaways

  • Split the problem: tiles, routing and traffic are three subsystems with different shapes.
  • The URL is the cache key for tiles, so a CDN removes most of the 69,000 requests per second.
  • Plain Dijkstra does not scale to a continent. Preprocess the graph with shortcuts so queries touch a small hierarchy.
  • Precomputed weights meet live traffic through customization or re-checking top candidates.
  • Version, don't purge: a new map is a new path, and sessions stay pinned to one version.
  • Degrade honestly: fall back to typical speeds and say so.

Further reading

  • R. Geisberger, P. Sanders, D. Schultes and D. Delling, "Contraction Hierarchies: Faster and Simpler Hierarchical Routing in Road Networks", Workshop on Experimental Algorithms (2008).
  • OpenStreetMap wiki, "Slippy map tilenames": the zoom, x, y tile addressing scheme.
  • Mapbox, "Mapbox Vector Tile Specification": the vector tile format.
  • P. Hart, N. Nilsson and B. Raphael, "A Formal Basis for the Heuristic Determination of Minimum Cost Paths", IEEE Transactions on Systems Science and Cybernetics (1968): the A* algorithm.

Check yourself

3 questions in this lesson. Answer each once to complete it.

Practice this

Lessons in this track