Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
System Design topics
Lesson 3/ 31
Fundamentals & Networking

DNS & Anycast Routing

Route global users to the closest healthy region before a single HTTP packet lands.

BeginnerGeoDNS · Anycast · TTL3 quiz questions0/2 subtopics done
Practice in AI HLD
In plain wordsDiagramTheorySubtopics (2)Step by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice
Deep-dive subtopics (2) - 0/2 completed
DNS Resolution & TTL Caching

Walk the Root → TLD → Authoritative lookup chain and choose smart TTLs.

Beginner
GeoDNS & Anycast BGP Routing

Send global users to the closest healthy edge or region automatically.

Intermediate

In plain words

DNS is the internet’s phone book. It turns a name like google.com into the numeric address computers use. Anycast lets many servers around the world share one address, so you reach the closest one.

Think of it like…

Calling 911: every city uses the same number, but the network automatically routes your call to the nearest dispatch center.

Where you’ve seen it

When you type netflix.com, DNS answers with an address, and anycast routing sends you to a nearby data center instead of one across the ocean.

Words you’ll hear

IP address
The numeric address of a machine on the internet, like 142.250.72.14.
TTL
Time to live: how long a DNS answer may be cached before asking again.
Resolver
The server (often your ISP’s) that looks up DNS names for you.
Anycast
Many servers announce the same IP; the network delivers you to the nearest one.

Visual diagram

Loading interactive diagram
Loading interactive exercise

Theory & deep dive

DNS is a distributed, cached phone book

Every time you open a website or call an API, your device needs an IP address like 142.250.72.14. Storing the entire internet’s names on one server would melt instantly, so DNS uses a tree hierarchy (Root → .com TLD → your Authoritative server) combined with aggressive caching at every step.

Each DNS answer carries a TTL (Time To Live) in seconds. High TTLs (e.g., 3600s) reduce DNS queries and improve speed, while low TTLs (30–60s) let you redirect users quickly during an outage.

Key takeaway: DNS trades instant updates for speed via TTL caching; lower TTL before a planned migration.

GeoDNS vs. Anycast BGP Routing

GeoDNS checks where the DNS resolver is located and returns the IP of the closest data center (e.g., Frankfurt for European users, Virginia for US East).

Anycast works one layer deeper at the internet routing layer (BGP): dozens of data centers around the world all announce the exact same IP address. Internet routers naturally carry packets along the shortest path to the nearest healthy location - giving instant failover in seconds without waiting for DNS TTLs to expire.

Key takeaway: GeoDNS picks a region at lookup time; Anycast routes every packet to the closest healthy PoP automatically.

How it works, step by step

Step 1 of 4
Client & ISP Resolver

1. Recursive resolver checks local caches

The browser checks its OS/browser DNS cache. On a miss, it queries a recursive resolver (e.g., 1.1.1.1, 8.8.8.8, ISP).

Cache hit = <1 ms · Cache miss triggers resolution
Key numbers at this step
Cache Key
Domain + Record Type
Bound
TTL

When to use it & trade-offs

What it is

DNS translates human-readable domains into IP addresses, while Anycast announces the same IP prefix from multiple global PoPs via BGP so routers pick the topologically nearest edge.

Why it matters: Every network connection starts with DNS; GeoDNS and Anycast slash cross-ocean latency and absorb DDoS floods at the network edge.

When to reach for it

  • Multi-region active-active applications needing low first-byte latency
  • DDoS protection and edge TLS termination via Anycast PoPs
  • Blue/green region draining during maintenance or regional outages

When to avoid or be careful

  • Relying solely on DNS with 24-hour TTLs for instant failover
  • Assuming GeoDNS always knows the exact user location when VPNs or central resolvers hide EDNS

Global Traffic Routing Options

Round-Robin DNS
Best for: Simple multi-IP distribution

Strengths: Zero infrastructure cost; supported by any DNS provider.

Watch out: No health awareness by default; clients may cache a dead IP.

GeoDNS / Latency-Based DNS
Best for: Routing users to regional L7 load balancers

Strengths: Steers traffic to the closest healthy region with active health checks.

Watch out: Respects TTL caches; stale ISP caches can delay failover.

BGP Anycast
Best for: CDNs, DNS servers, edge DDoS absorption

Strengths: Instant network-level rerouting; single IP globally.

Watch out: Long-lived TCP connections can break if BGP routes flap mid-stream.

Interview signals & numbers to know

When this topic comes up

  • global users
  • multi-region
  • nearest data center
  • DDoS mitigation
  • failover

Benchmarks & rules of thumb

DNS lookup latency (cold) -
20–120 ms
Failover TTL -
30–60 seconds
UDP packet limit (classic) -
512 bytes (EDNS0 up to 4 KB)
Anycast PoP RTT -
5–25 ms

Common mistakes & follow-ups

Common interview mistakes

  • Expecting a DNS change to propagate instantaneously - recursive resolvers and browsers honor TTL
  • Putting CNAME at the zone apex (root domain) instead of ALIAS/ANAME
  • Using Anycast directly for stateful long-lived TCP connections without pinning at the edge

Likely interviewer follow-ups

  • Why might a user still hit a failed region for minutes after DNS health checks flip?
  • How do CDNs combine Anycast at the edge with regional origin routing?
  • How do you protect DNS records from spoofing or cache poisoning (DNSSEC)?
Interview tip: Mention DNS TTL explicitly whenever you propose DNS-based regional failover.

Knowledge check

Loading quiz

Put it into practice

Design full architectures with AI feedback

Apply DNS & Anycast Routing inside real High-Level Design prompts or review Q&A flashcards.

Open AI HLD Practice →SD Interview Q&A
Previous topic
Scalability
Next topic
Load Balancing & Proxies