Lesson 10 of 13 · Designing the edge
Global traffic and failover
Send each user to the right region and keep serving when a region fails. DNS-based steering (geo, latency, weighted, failover) and its TTL trap, anycast global load balancers, health checks that reflect real user experience, active-active vs active-passive, residency rules that limit where traffic may go, sessions across regions, and how to rehearse a failover.
Why go global
- Latency: users far from your only region wait on every round trip.
- Availability: a region-wide failure shouldn't be a company-wide outage.
- Residency: some customers' data must stay in a country or area.
Each reason changes the design; know which ones you're solving before choosing tools.
A pizza chain with shops in several towns: the phone line sends your call to the nearest shop (steering). If one shop's oven breaks, calls go to the next town (failover), as long as that shop has enough cooks (capacity) and knows your previous orders (data). Some customers only allow shops in their own country to have their address (residency).
DNS-based steering
The DNS answer differs by who asks:
| Policy | Answer | Good for |
|---|---|---|
| Geo | By the resolver's country or continent | Residency, simple regional split |
| Latency | The region with the lowest measured latency from that network | Performance |
| Weighted | Regions by percentage | Gradual region launches, load sharing |
| Failover | Primary while healthy, otherwise secondary | Active-passive |
Examples: Route 53 routing policies, Azure Traffic Manager, Cloud DNS routing policies, and most DNS providers.
The TTL trap: resolvers and clients cache answers for the record's TTL (and some cache longer). With a 300-second TTL, many users keep going to a dead region for 5 minutes or more after failover. Use low TTLs (30 to 60 seconds) for failover records, and accept more DNS queries.
Anycast global load balancers
A global load balancer (for example AWS Global Accelerator, CloudFront, Azure Front Door, Google Cloud's global external load balancer, CDN providers) announces one IP address from many locations. Users connect to the nearest edge; the provider steers to healthy origins behind it.
- Failover in seconds, without DNS caching.
- One address to allow-list for partners.
- TLS termination, WAF and caching in the same place (lesson 9).
- Costs and lock-in to that provider's edge.
Health checks that mean something
| Check | Signal |
|---|---|
| TCP port open | Process is listening (almost useless for failover) |
GET /healthz |
Process thinks it's healthy |
| Synthetic transaction | A real request path works: sign in, read, write a test record |
Use the deepest check that's still cheap and safe, from several locations, and require several failures in a row before failing over, so one bad probe doesn't move all traffic.
Active-passive or active-active
| Active-passive | Active-active | |
|---|---|---|
| Traffic | One region serves; the other waits (warm standby) | All regions serve |
| Data | Replicated to the standby; writes in one place | Writes in several places, or each user "homed" to one region |
| Failover | Promote the standby; minutes | Shift traffic; seconds to minutes |
| Cost | Standby capacity mostly idle | Capacity used, but each region needs headroom to absorb another's load |
| Difficulty | Medium | High, mostly because of data |
A practical middle ground for multi-tenant SaaS: each tenant has a home region (active-active across tenants, active-passive per tenant). Traffic for tenant A goes to region 1, tenant B to region 2; each region is the standby for the other's tenants, within residency rules. The multi-tenant SaaS course's global edge lesson shows this with cells.
Residency and steering
- Steering must know which regions a tenant may use, not just which is fastest.
- Failover targets must be allowed regions too; sometimes the right answer is "degrade, don't move".
- Backups, logs and support access follow the same rules.
Sessions across regions
- Stateless services (state in tokens or a shared store) move between regions freely.
- Sticky sessions (cookie or IP affinity) keep a user on one region or pod; they break on failover, so make sure a moved user can re-authenticate or recover.
- Avoid storing important session state only in one region's memory or cache.
Rehearse failover
- Write the runbook: trigger, who decides, steps, how to verify, how to fail back.
- Run a drill in a quiet period: fail a region on purpose (drain it at the global load balancer).
- Measure RTO (time until users are served again) and RPO (data lost, from replication lag).
- Check capacity: did the surviving region autoscale in time?
- Fail back, and fix what surprised you.
Try it
- Look up the TTL of a few big sites' DNS records (
dig +noall +answer example.com). What does each TTL tell you about their failover approach? - For your own product, decide per reason (latency, availability, residency) whether you need multiple regions, and which steering method fits.
- Write the failover runbook for one service: health signal, decision, steps, verification, fail-back.
- Calculate the headroom each of three active-active regions needs so that any two can absorb the third's traffic.
Going deeper
- Split brain: if both regions think they're primary, writes diverge. Use a single authority (a managed database's failover, a consensus system) to decide who may write.
- Cell routers in multi-region designs route per tenant, so a region failure affects only the tenants homed there.
- Fail over gradually where possible (weights 100/0 → 50/50 → 0/100) to avoid overwhelming the surviving region's cold caches.
Recap
- Go global for latency, availability or residency, and know which.
- DNS steering is simple but limited by caching; anycast global load balancers fail over in seconds.
- Health checks should follow a real user path, from several locations.
- Active-active is mostly a data problem; homing tenants to regions is a practical middle ground.
- Residency limits failover targets; rehearse failover and measure RTO and RPO.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.