How to design Google Maps
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
On this page
The problem
Google Maps serves a map to about a billion people a day, plans a route with an arrival time, and changes that route while the driver is still on the road. The map side is a read problem: the world is cut into small square tiles that are drawn ahead of time and handed out from the edge, so almost no request reaches a server that draws anything. The navigation side is a write problem that doesn't pause: moving phones keep reporting where they are, those reports become traffic per road segment, and when a road closes the system has to find the routes that pass through it and reach those drivers over a connection that's already open. The answer turns on keeping those two sides apart and sizing each for its own load.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
How many people use it, and how often does a navigating phone report where it is? | The user count sizes the tile reads; the report rate sizes the write path, which is the part that is hardest to keep up with. | About 1 billion daily users who navigate about 35 minutes a week each. With the app batching GPS points, that's about 200,000 location requests a second on average and 1 million at peak. |
Which ways of getting around, and does a route have to change while the driver is on it? | Walking and biking are a different cost model on the same graph; live rerouting is what forces a channel from server to phone and a record of who is on which road. | Driving, walking and biking, each with an arrival time. Yes: when traffic or an incident makes a faster route available, the driver should get it without asking. |
Is the map a set of pictures, or data the phone draws itself? | It decides bandwidth per tile, how much work the device does, and whether the client can restyle or rotate the map on its own. | Either is acceptable; the interviewer will ask you to pick one and defend it. Phones are the main device, so mobile data and battery weigh on the choice. |
How fresh does traffic have to be, and how fast should a driver hear about a closure? | The freshness target sets the batch interval on the phone, the window length in the stream job, and whether polling is even an option. | Close to live. A crash at rush hour should reach the drivers headed for it well before they arrive at it; put a number on the pieces of that delay as you go. |
Do we keep location history, or just each phone's latest position? | History is what traffic detection and road-data improvement are built from, and it's a large write volume. Keeping it means a write-oriented store and a retention policy. | Keep it. It feeds traffic detection and improves the road data over time; how long to keep it is your call, and say what it costs. |
Is it phones, or web browsers too? | If web browsers also navigate, a channel that works on phones but not in a browser, such as mobile push, is ruled out for reroutes. | Mostly phones, but the design shouldn't shut out the web. That matters for the reroute channel. |
Are routes with several stops, business listings and photos part of this? | Each is its own system; agreeing they're out keeps the round on tiles, routing and traffic. | No. Routes with several stops, business places and photos are out of scope. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
1 billion daily users | Map reads at this scale have to be answered from copies near the user, not by servers that draw pictures on demand. Anything on the per-user hot path, a tile fetch or a route request, has to be a cheap lookup or a file read. |
About 200,000 location updates a second, 1 million at peak | The write path is append-heavy and has to accept a burst five times the average without dropping data. The phone batches its points, the service writes to a store built for appends and hands each batch to a log, and the consumers that turn points into traffic scale on their own. |
Accurate directions and smooth map rendering | Routing runs over a road graph with current speeds, and the ETA has to use traffic that is close to live. Rendering stays smooth when the tiles for the next pan are already on the device, so the client fetches a ring around the visible area. |
Light on mobile data and battery | GPS points don't travel one at a time: the phone accumulates them and sends a batch. Tiles are small, which favors vector data over images, and one held-open connection replaces a timer that sends a request which usually returns nothing new. |
Highly available | A stale position is better than a rejected write, so the location store favors availability over consistency. Tiles live on a CDN with many copies, the request-serving services are stateless so any instance can answer, and the WebSocket servers, which do hold state, lose their connections when one dies, so the apps reopen them elsewhere. |
Estimates
| Quantity | Working | Result | What it sizes |
|---|---|---|---|
Navigation minutes a day | 1 billion users × 35 minutes a week ÷ 7 days = 5 billion minutes a day | About 5 billion minutes of navigation a day | The base figure for how many phones are being guided at any moment and how many location reports they send. |
Phones navigating at the same time | 5 billion minutes a day ÷ 1,440 minutes a day (24 × 60) ≈ 3.5 million | About 3.5 million phones navigating at once, on average | How many WebSocket connections the connection servers hold, and how many active-route rows an incident has to search. |
Location requests per navigating phone | 3.5 million phones ÷ 200,000 requests a second ≈ one request per 17 seconds per phone; if each GPS point (one a second) were its own request, 3.5 million requests a second | A batch about once per 17 seconds; sending points one by one would mean about 17 times the request rate | Why the client batches, and the lag a batch adds before a slowdown is visible to the stream job. |
Bytes into Kafka | 200,000 requests a second × 17 points × about 50 bytes a point (user id, timestamp, latitude, longitude) ≈ 170 MB a second; at the peak of 1 million requests a second ≈ 850 MB a second | About 170 MB a second on average, 850 MB a second at peak | How many Kafka partitions and brokers the location topic needs, and the network into them. |
Location points stored a day | 3.5 million points a second × 86,400 seconds ≈ 300 billion points a day; × 50 bytes ≈ 15 TB a day | About 300 billion rows and 15 TB a day before compression | The growth of the Cassandra cluster and why a retention period, or a rollup of old points, has to be decided. |
Tiles at the deepest zoom level | One tile at zoom zero and four times as many at each level, so 4^21 ≈ 4.4 trillion tiles at zoom 21; at an assumed 100 KB a tile ≈ 440 PB before any sharing of look-alike tiles | About 4.4 trillion tiles at the deepest level; the 70 PB figure counts on look-alike tiles such as deserts compressing very well | Where tiles live: a key-to-blob object store, not a database, with a CDN holding the popular subset. |
Tile fetches a second | 1 billion users × an assumed 50 tiles a session = 50 billion fetches a day ÷ 86,400 seconds ≈ 580,000 a second | About 580,000 tile fetches a second on average | Why tiles are precomputed and served from the CDN rather than drawn when asked for. |
Cost of scanning all routes for one incident | 3.5 million active routes × an assumed 50 routing tiles a route = 175 million tile comparisons for each incident | About 175 million comparisons per incident without an index | Why active routes are indexed by the routing tiles they pass through, so an incident looks up its routes instead of scanning. |
Core entities
| Entity | What it holds |
|---|---|
Routing tile | The road graph of one area at one level of detail: intersections as nodes, roads as edges, built offline and stored as a file. |
Map tile | One square of the drawn map at one zoom level, addressed by geohash and zoom, holding either an image or vector shapes. |
User location | One GPS report: who, when and where. Written in batches and read by the traffic detection job. |
Geocoding entry | An address and its coordinates, in a key-value store because it's read far more often than it changes. |
Active route | One navigation in progress: the route being followed and which routing tiles it passes through, so an incident can find it. |
Traffic segment | The current speed on one road segment, derived from the location stream and kept per routing tile. |
The API
| Endpoint | Notes |
|---|---|
| The phone accumulates GPS points and sends them as one batch, about once per 17 seconds in this design. The service writes the rows to Cassandra, publishes the batch to Kafka and answers; nothing waits on traffic detection. Rows are keyed by user and timestamp, as in the chapter's data model. Include the active route id while navigating. |
| If origin or destination is text, it's geocoded first from the key-value store. The route planner loads the routing tiles between the two points, coarse tiles for the long middle and fine tiles at each end, the ETA service prices the candidates with current traffic and a ranker picks. When the user starts navigating, the service records an active route with the tiles it passes through. |
| The client computes the geohash of each cell in its viewport at the current zoom and fetches from the CDN; a miss goes to object storage. The URL carries a version, so a rebuilt tile gets a new URL and old copies age out at the edge instead of being purged. A small tile URL service can hand out the URL instead, which costs a round trip but lets the scheme change without a client update. |
The high-level design
Step 1 of 4
Directions and a map that are computed ahead of time
Start with the two things everyone uses. For directions, a navigation service answers GET /v1/nav: it geocodes the ends, loads routing tiles (the road graph cut into areas, with coarse tiles holding highways and fine tiles holding streets), runs a shortest-path search and returns a polyline with steps and a duration. The routing tiles are built offline from road data and kept as files in object storage, cached hard in the service. For the map, an offline pipeline draws the world as tiles at each zoom level and stores them in object storage; the client fetches the ones in its viewport from a CDN edge. Nothing in this step knows where any driver is, so the duration is a guess from free-flow speeds and a route doesn't change once given.
What breaks first
The deep dives
Live traffic and rerouting. A crash closes a highway at rush hour. How do the drivers already heading toward it find out and get a new route, and which parts of the design decide how long that takes?
Serving map tiles. A billion people open the map and pan and zoom around it. How do the tiles reach their screens quickly over a phone connection, and what does 70 PB of them mean for where they're kept?
A concept that helps here: Tile pyramids and zoom levels
A concept that helps here: Geospatial indexingConcepts this guide uses
- WebSockets, server-sent events and polling
- Stream processing and windows
- Geospatial indexing
- CDNs and edge caching
- Tile pyramids and zoom levels
Sources
- Alex Xu, System Design Interview, chapter 19: Google Maps (notes by Preslav Mihaylov)
- Alex Xu, System Design Interview volume 2, chapter 19: Google Maps (notes at books.dwf.dev)
- Wikipedia: Tiled web map
- Wikipedia: Geohash
- Mapbox docs: Vector tiles standards
- Google DeepMind: Traffic prediction with advanced Graph Neural Networks
- AlgoMaster: Long Polling vs SSE vs WebSockets
- Firebase Cloud Messaging: message types
- Apache Cassandra documentation: Storage Engine
- Confluent: Introduction to Apache Kafka