00.3 Multiple data centers & geo-routing

Mid-level · Component

Core idea

Running in two or more data centers keeps you available through a regional outage and gives faraway users lower latency. Geo-aware DNS sends each user to the closest healthy site; the hard part is keeping data in sync.

Mental model

A chain of shops in different cities, each stocked with the same products. Customers go to the nearest one. If one shop floods, a sign sends everyone to the next nearest. The difficulty is making sure every shop has the same stock list, even while sales happen everywhere at once.

Why it matters

  • A single data center is a single point of failure for the whole business
  • Distance adds latency that no amount of code optimisation removes
  • Large products are expected to survive an entire region going down

What to know

  • geoDNS resolves the same domain to different IPs depending on the user’s location
  • Normal operation splits traffic by region; during an outage all traffic shifts to the healthy site
  • Data synchronisation: replicate data across sites, often asynchronously, and decide how to resolve conflicts
  • Users may land in a site that lacks their latest data right after a failover
  • Testing and deployment must be automated and consistent across every site
  • Each data center should hold enough spare capacity to absorb a failed neighbour’s traffic

Common traps

  • Assuming replication is instant; cross-region lag is real and users can see stale data
  • Deploying different versions to different sites by hand, causing subtle inconsistencies
  • Running two sites at 80% each: when one fails the other cannot take the load

Recognise it

Recognition trigger: ‘Global users’ or ‘must survive a region outage’ → multi-data-center with geoDNS, replicated data, automated deployment and spare capacity per site.

Practice question

A whole data center goes offline. Walk me through what users experience, how traffic moves, and what could go wrong with their data.

Apply at work

Answer these for the system you work on.

Go deeper