Network & Geo

DNS & Geo Routing

Send users to the right region or stack with DNS and geo / latency routing.

Intermediate, about 60 minutes to read, 4 open questions to practise.

1Understand

The idea

DNS and geo routing influence which region, POP, or load balancer a client reaches before TCP connects to your app. Geo/latency, weighted, failover, and Anycast policies shape traffic, but DNS does not replicate databases or heal unhealthy origins by itself.

TTL caps how fast steering changes propagate: TTL 3600 means many clients keep a dead IP for an hour. Pair DNS with LB health checks and honest failover SLAs. Multi-region answers must cover data gravity: where writes land, replication lag, and whether EU users can write if primary is US-only.

Anycast front doors (one IP, BGP to nearest POP) complement per-region A records, both are fair game in interviews with different tradeoffs.

Intuition

DNS does vs does not. Returns addresses for names; caches aggressively (resolver, OS, browser, some mobile apps ignore low TTL). Does not know app health unless provider combines health-checked records.

Policies. Geo: continent/country → regional stack. Latency: probe RTT pick lowest (within provider constraints). Weighted: canary 95/5, coarse; LB weights often finer/faster rollback. Failover: primary/secondary record sets when health check fails.

TTL tradeoff. Low TTL (60-300s) faster steering; more DNS QPS and resolver load. High TTL stable but slow disaster cutover, state both numbers when promising “minutes” failover.

Anycast. Same IP announced from multiple PoPs; BGP routes to nearby edge; L7/LB behind still regional for data.

Active-active vs active-passive. Active-passive: one write region; DR promote on disaster (RPO async). Active-active: local latency; conflict resolution hard, say write home region unless CRDT story exists.

Steer without data trap: EU DNS → EU API but profiles only in US DB → broken writes.

Client behavior: connection pools pin to region briefly after DNS change, mention drain at LB.

GSLB vs DNS (one line). Some clouds offer global load balancing with health checks independent of resolver TTL, still need data story behind each target.

Compliance routing: data residency laws may forbid serving EU users from US stack even if latency is lower, legal constraint overrides pure RTT optimization.

Measuring steering. Compare regional p95 from RUM, DNS change without latency win is vanity; roll back weighted policy.

Private resolvers. Enterprise customers using custom DNS forwarders may ignore your TTL, document stickiness for B2B VPN users.

What you will be able to do

  • Choose a DNS routing policy for multi-region
  • Relate TTL to failover speed
  • Separate traffic steering from data replication

When this comes up

  • Multi-region
  • GeoDNS
  • Anycast
  • Failover DNS TTLs

2See it

Architecture sketch

DNS steers before TCP

Resolver returns a nearby VIP. Health and data gravity still matter after the A record.

100%
ClientGatewayService

Walkthrough

TTL and failover lag

DNS is not instant health

1 / 4

100%

User resolves api.example.com. Answer is cached at resolvers for TTL seconds.

Read the walkthrough as text

Worked example, global SaaS API `api.example.com` with US primary, EU read replica, US-DR failover.

  1. Happy path: GeoDNS returns regional ALB in us-east or eu-west based on resolver location/latency.
  2. TTL: 120s on production records if runbook targets <5m regional steering; admit worst-case cache stickiness.
  3. Writes: primary in US; EU serves reads from replica lag 1-3s, session-critical reads can route to US leader or use sync token.
  4. US region down: health checks fail → failover record to US-DR ALB; runbook flip; RPO stated for async replication.
  5. Not DNS-only: ALB drains unhealthy targets continuously; DNS is coarse backup.
  6. Canary: prefer LB weight 5% to new target group vs DNS 5% (faster rollback).
  7. Anycast alt: single anycast IP to global edge POP; origins remain regional behind.
  8. Game day: quarterly region evacuation drill measures real RTO vs PowerPoint.

What interviewers listen for: TTL vs SLA honesty; data replication with routing; LB health + DNS; steer-without-data avoided.

Napkin math

DNS / geo napkin

lookup → A/AAAA for nearest VIP

TTL = 30-60s (failover lag ≈ TTL)

geo DNS is not instant health; keep LB checks

data gravity: serve from region that holds data

anycast VIP for L4 near users when needed

DNS steers traffic. It does not heal a dead region instantly.

3Answer it

How to answer in an interview

When worldwide users, multi-region, disaster recovery:

  1. Regions & roles, active-active or active-passive.
  2. Routing policy, geo, latency, weighted, failover, anycast.
  3. TTL vs failover time, numeric honesty.
  4. Data. Write home, replication lag, read consistency per region.
  5. Health, LB checks + automated failover.
  6. Drills, region down, stale DNS, connection pools.

Phrases: “DNS is cached,” “routing without data is useless,” “health-checked LB is the fast loop.”

  1. Close: if you promise multi-region, promise replication lag number or write-home region.

Answer checklist

1. How many regions / stacks? 2. Routing policy (geo, latency, weighted, failover). 3. DNS TTL vs how fast you can cut over. 4. Data gravity, where writes go. 5. Failure: region down, DNS cache staleness.

Tradeoffs & numbers

  • Low TTL: responsive steering; more DNS load and resolver chatter.
  • GeoDNS: lower RTT; uneven load if geo skewed vs traffic.
  • Active-active: best latency; hardest writes, need conflict plan.
  • DNS failover: simple; slower than anycast/LB drain alone.
  • Weighted DNS canary: minute-scale; LB weights second-scale.
  • When NOT geo split: tiny single-region product; team cannot operate multi-region data, say “single region + CDN” instead.
  • Regulatory override: privacy law may forbid routing EU citizens to US stack even if latency wins.
  • Observability: per-region SLIs, geo steering fails silently if one region error budget burns.
  • Interview tip: state TTL in seconds when promising failover minutes, converts hand-wave to math.
  • Chaos drill: game-day region evacuation validates steering *and* data promotion scripts together.
  • Split-horizon DNS: corp VPN users may resolve differently from public resolvers, call out if B2B VPN is in scope.
  • CNAME chains: each hop adds lookup latency, flatten with ALIAS where possible.

Kinds of questions (4)

Same pattern, different interview surfaces. Recognise which variant you are in before you answer.

  • GeoDNS to nearest region

    Example. APAC users hit Singapore stack instead of Virginia by default to shave 180ms RTT. Pair DNS policy with LB health checks, TTL vs failover speed, and where writes land in multi-region (data gravity).

    How. Latency or geo policy on apex; ensure APAC can read local replica; writes still home to primary or multi-master with conflict rules stated.

  • Active-passive DNS failover

    Example. Primary region flood; DR must take DNS traffic within ten minutes. Pair DNS policy with LB health checks, TTL vs failover speed, and where writes land in multi-region (data gravity).

    How. Health-checked failover record; TTL 120s stated; LB drains; runbook RPO for async replication; no “instant” with TTL 3600.

  • Weighted / canary DNS

    Example. Soak test new API stack with 5% of global DNS answers before full cutover. Pair DNS policy with LB health checks, TTL vs failover speed, and where writes land in multi-region (data gravity).

    How. Weighted records; measure error budget; prefer LB target weights for faster rollback than DNS propagation alone. Low TTL tradeoff; health-checked origins; explicit primary write region and replica lag for reads.

  • Anycast LB front door

    Example. DDoS scrubbing POP anycast advertises one IP worldwide for edge TLS termination. Pair DNS policy with LB health checks, TTL vs failover speed, and where writes land in multi-region (data gravity).

    How. BGP nearest POP; origin clusters still regional; contrast with per-continent A records to different ALBs. Low TTL tradeoff; health-checked origins; explicit primary write region and replica lag for reads.

Common mistakes

Failure modes the AI coach watches for when you practise open questions.

DNS vs data

Avoid. Geo DNS only. Users land in EU while primary DB is US-write-only with no story.

Prefer. DNS + regional LB + explicit primary/replica (or multi-primary) plan.

Weak sketch

Bad

100%

Stronger sketch

Good

100%
  • TTL too long

    Why it happens. Resolvers and mobile caches honor TTL; long TTL means traffic keeps flowing to failed region for the full cache window.

    How it fails. Marketing promises 2-minute DR failover while apex record TTL remains 3600 seconds.

    Fix. Lower TTL before migration season; quote failover as TTL plus health-check detection plus drain time.

  • Steer without data plan

    Why it happens. Routing users to a region without their rows causes write failures, 404s, or dangerous stale reads served as fresh.

    How it fails. GeoDNS sends Australian users to `ap-southeast` API but accounts table is US-primary only with no replication.

    Fix. Replicate data or restrict geo routes to read-only; define write-home region and lag budget.

  • DNS-only HA

    Why it happens. DNS lacks sub-minute awareness of dead backends; manual record edits lag incidents and depend on human runbooks.

    How it fails. HA story is “engineer edits Route53 when PagerDuty fires” with no automated health-checked target drain.

    Fix. LB health checks remove bad targets quickly; DNS failover as coarser backup with aligned TTL.

4Practise

Concept check

A short quiz on this lesson before open questions. Optional, and it does not gate practice.

Open questions

Ready to practise?

Write an answer, get AI coaching, then revise. You are not building a real system.

Practise with an open question

All systems lessons