NetworkingDNS

DNS (Domain Name System) translates human-readable domain names like google.com into IP addresses. It's the phone book of the internet and a key lever for global traffic routing.

What is DNS?

DNS translates domain names (e.g., leetdesign.com) into IP addresses (e.g., 104.21.45.83) that computers use to locate each other on the internet. Without DNS, you'd need to memorize IP addresses to visit websites.

DNS Resolution Process

Browser → Recursive Resolver (ISP or 8.8.8.8)
         → Root Name Server (knows TLD servers)
         → TLD Name Server (.com, .org, etc.)
         → Authoritative Name Server (your DNS provider)
         → IP Address returned to browser
  1. Browser checks local cache
  2. Checks OS cache
  3. Queries recursive resolver (e.g., your ISP or Google's 8.8.8.8)
  4. Resolver queries root servers → TLD servers → authoritative servers
  5. IP returned and cached at each layer per the TTL

Key DNS Record Types

| Record | Purpose | Example | |---|---|---| | A | Maps domain → IPv4 address | leetdesign.com → 104.21.45.83 | | AAAA | Maps domain → IPv6 address | leetdesign.com → 2606:... | | CNAME | Alias one domain to another | www.example.com → example.com | | MX | Mail server for a domain | example.com → mail.example.com | | TXT | Arbitrary text (used for verification, SPF) | Domain ownership proofs | | NS | Specifies the authoritative name servers | example.com → ns1.cloudflare.com |

TTL (Time to Live)

TTL controls how long DNS responses are cached at each resolver. A low TTL (60 seconds) means changes propagate quickly but increase DNS query load. A high TTL (86400 = 24 hours) is efficient but means DNS changes take longer to propagate.

Strategy:

  • Lower TTL before major changes (e.g., traffic migrations, deployments)
  • Use higher TTL during stable periods to reduce DNS load

DNS for System Design

GeoDNS / Latency-Based Routing

Return different IP addresses based on the user's geographic location. Users in Europe get routed to EU servers; users in Asia get routed to Asia-Pacific servers. This is how global applications achieve low latency.

DNS Load Balancing

Return multiple A records for the same domain. Clients round-robin across them. Simple but crude — doesn't health check or respond to actual server load.

DNS Failover

Monitor origin servers and automatically update DNS to point to a backup server if the primary fails. Recovery depends on TTL (could take minutes to hours for changes to propagate).

Traffic Shifting / Blue-Green Deployments

Slowly shift traffic from old (blue) to new (green) infrastructure by updating DNS records, changing weights gradually.

DNS as a Single Point of Failure

If your DNS provider goes down, your entire service is unreachable — even if your servers are perfectly healthy. Use multiple DNS providers and DNS redundancy. Several major outages (Fastly 2021, Dyn 2016) have taken down large portions of the internet.

Interview Tips

  • Bring up GeoDNS when designing systems with global user bases
  • Mention that DNS changes are slow to propagate (due to caching/TTL) — this matters for incident response
  • DNS is often overlooked as a layer for traffic management, but it's powerful
  • Know that DNS lookups add latency — browsers cache DNS responses to mitigate this