DNS and How the Internet Works

beginner 0-2 YOE system-design DNS networking internet

Before we can design any system, we need to understand how a request gets from a user’s browser to our server. It all starts with DNS — the phone book of the internet.

What Happens When We Type a URL?

From URL to Response
1. Browser checks its DNS cache
   ↓ not found?
2. OS checks its DNS cache
   ↓ not found?
3. Query goes to DNS Resolver (ISP)
   ↓ not found?
4. Resolver asks Root → TLD (.com) → Authoritative DNS
   ↓ got the IP!
5. Browser opens TCP connection (+ TLS handshake for HTTPS)
   ↓
6. Browser sends HTTP request → Server responds
   ↓
7. Browser renders the page

In simple language, DNS translates human-readable names (like google.com) into IP addresses (like 142.250.80.46) that computers understand. Without DNS, we’d have to memorize IP addresses for every website.

How DNS Resolution Works

DNS has a hierarchy, like asking directions from more and more knowledgeable people:

  1. DNS Resolver (our ISP or something like 8.8.8.8) — The starting point. It does the legwork.
  2. Root Name Server — Knows which servers handle .com, .org, .io, etc. There are only 13 root server clusters worldwide.
  3. TLD Name Server — Handles a specific top-level domain (like all .com domains). Points to the authoritative server.
  4. Authoritative Name Server — The final answer. This server actually knows what IP google.com maps to.

The result gets cached at every level (browser, OS, resolver) with a TTL (Time To Live). That’s why DNS changes take time to propagate — old cached entries have to expire first.

DNS Record Types We Should Know

Record TypeWhat It DoesExample
AMaps domain to IPv4 addresspman47.cc → 144.24.126.230
AAAAMaps domain to IPv6 addresspman47.cc → 2001:0db8::1
CNAMEAlias for another domainwww.pman47.cc → pman47.cc
NSDelegates to a name serverpman47.cc → ns1.hostinger.com
MXMail server for the domainpman47.cc → mail.pman47.cc

Why DNS Matters in System Design

DNS isn’t just “it resolves names.” In system design, DNS is a powerful tool:

Load distribution — DNS can return different IPs for the same domain, spreading traffic across multiple servers (DNS round-robin).

Geo-routing — DNS can return the IP of the server closest to the user. A user in India gets routed to the Mumbai server, while a user in the US hits the Virginia server.

Failover — If a server goes down, DNS can stop returning its IP. Health checks detect the failure, and DNS automatically routes traffic to healthy servers.

CDN routing — Services like CloudFront and Cloudflare use DNS to route users to the nearest edge server.

DNS in Our System Designs

When we’re drawing system design diagrams, DNS is usually the very first step:

User → DNS → Load Balancer → Application Servers → Database

We don’t usually deep-dive into DNS in interviews unless asked, but we should always mention it. It shows we understand the full picture — not just the backend.

Quick Gotchas

  • DNS propagation delay: Changing DNS records can take up to 48 hours because of caching at various levels. In practice, it’s usually faster.
  • DNS is a SPOF (sort of): If our DNS provider goes down, nobody can reach us. That’s why companies like Netflix use multiple DNS providers.
  • TTL trade-off: Short TTL = faster failover but more DNS queries. Long TTL = fewer queries but slower to react to changes.

In simple language, DNS is the first thing that happens in any web request. It’s simple in concept but powerful in practice — it can do load balancing, geo-routing, and failover, all before a single HTTP request is made.