Skip to content
System Designer

Hard · Mobility and logistics

Maps and routing

You run a maps app with places, routes and live traffic. Map pictures never change much, but route lookups, place search and traffic from moving phones do. Soon a whole new continent will start using it. Keep maps fast everywhere without paying to serve the same picture twice. Practise this hard system design problem for free with a Google or GitHub account.

The brief

You run a maps app with places, routes and live traffic. Map pictures never change much, but route lookups, place search and traffic from moving phones do. Soon a whole new continent will start using it. Keep maps fast everywhere without paying to serve the same picture twice.

Think of a maps app like Google Maps.

Users, scale and requirements

Who uses it
20 million people a month (approx.)
Audience in plain numbers
20,000,000 people per month
Normal peak
≈ 12,000 requests per second
Request mix
Read: 65%; Search: 13%; Location ping: 20%; Write: 2%
Speed for 99 of 100 requests
Read: ≈ 350 ms; Search: ≈ 500 ms; Write: ≈ 350 ms
Successful requests
99.9%
Data safety
At most 1 minute of writes may be lost.
Monthly budget
≈ $41,000
Data at rest
≈ 90 TB
Where users are
North America: 50%; Europe: 35%; Asia Pacific: 15%
Home region
North America
Waiting deadlines
Read: 900 seconds; Search: 900 seconds; Location ping: 900 seconds; Write: 3,600 seconds

≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.

  • Reads are map tiles (about 85 percent) and route or place-card lookups (about 15 percent). A tile is about 4 KB here (approx.).
  • Map imagery for the world is on the order of 80 TB at several zoom levels (approx.).
  • All numbers are rough approximations.

Questions that shape the design

How fresh must map pictures be?

Map tiles change maybe once a day. A tile can be kept for hours or longer.

How fresh must traffic be?

About a minute. Phones on the road send speed pings, and the app uses the latest average per road.

Can a route be reused for another person?

Popular routes can. Many people ask for the same commute, so route answers are worth keeping for a few minutes.

Where do users live?

Half in North America and a third in Europe today. After the new-continent launch, a big share will be in Asia Pacific.

The traffic day

Traffic following users around the world. The clock covers 00:00 to 24:00 in the home region. Events add pressure on top of that normal traffic.

  1. 08:00 · Overseas launch

    A launch brings users who are far from your servers.

    Affected share: 40%.

  2. 13:00 · Viral spike

    A post blows up. Traffic climbs to several times normal within minutes.

    Traffic for Read, Search reaches 4 times the scheduled load; rises over 600 seconds, holds for 3,600 seconds and eases over 3,600 seconds. Other request types keep their scheduled load.

  3. 17:00 · Cache stampede

    The cache empties (restart, purge, mass expiry) and every request rushes to the database at once.

    Recovery window: ≈ 300 seconds.

What a strong design has to handle

  • Most requests ask for a picture that was the same yesterday. Where is the cheapest place to keep a copy near the user?
  • Separate reusable map tiles from versioned routes and fresh traffic.
  • A one-day tile keep time makes the CDN bill small and means a fixed map error can take up to a day to disappear, unless you purge it.
  • Collapsing misses protects the origin when the cache empties, and makes the first few viewers of each tile wait together.

Make a prediction, run a full traffic day, then compare the result. The in-game editorial opens after a finished day and includes measured reference designs.

Concepts to practise

Related problems