GSLB, GeoDNS and Anycast

How global traffic is sent to the right region: DNS that answers differently by location, latency or health, and anycast, where many sites share one IP address and the internet's routing picks the nearest.

Overview

Global server load balancing (GSLB) decides which region or site a user's request goes to, when the same service runs in several places around the world. The goals are low latency (send users somewhere close), availability (stop sending them to a site that is down) and control (keep some users in a country, or shift a share of traffic for a test).

There are two main ways to do it. DNS-based routing gives different answers to the same name: the authoritative DNS server looks at where the query came from, at measured latency or at health checks, and returns the address of the chosen region. GeoDNS and latency-based routing are both forms of this. Anycast gives every site the same IP address and lets the internet's routing protocol, BGP, deliver each user's packets to the nearest site that announces it.

Both work before a single request reaches your servers, so they are easy to get wrong in ways that are hard to see: users routed by where their DNS resolver is instead of where they are, failovers that take minutes because answers are cached, and TCP connections that could break when routes change. This topic covers how each method works, what it costs and how large systems combine them.

What you will be able to do

  • Explain how an authoritative DNS server chooses an answer by location, latency, weight or health.
  • Work out how long a DNS failover takes, and what shortens it.
  • Explain the resolver-location problem and how EDNS Client Subnet addresses it.
  • Explain anycast, why it suits DNS and CDNs, and how it is made to work for TCP services.
  • Choose between DNS routing and anycast for a design, and combine them with regional load balancers.

Key concepts

  • Global server load balancing
  • GeoDNS
  • Latency-based routing
  • EDNS Client Subnet
  • DNS health checks
  • TTL and failover time
  • Anycast and BGP
  • Anycast and TCP

Interview questions

  • How does GeoDNS work, and what are its limits?
  • Your region goes down. How long until users stop reaching it with DNS failover, and how do you make it faster?
  • What is anycast, and why does it suit DNS and CDNs?
  • Can you run TCP services over anycast?
  • Latency-based routing or geolocation routing: when do you use each?
  • Design global traffic management for an API served from three regions.
  • What is EDNS Client Subnet, and what are its downsides?
  • What can go wrong with anycast itself?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio