DNS (Domain Name System) is the internet's phone book: it translates a human-readable name like example.com into the IP address a computer needs to connect to. It is a globally distributed, heavily cached, hierarchical database, and it runs before almost every request your system receives.
In simple words
DNS is the phone's contact list for the internet. You tap "Mom" and the phone looks up her number; you type example.com and DNS looks up the server's IP address. The lookup is remembered for a while so it's fast next time.
The resolver asks root → TLD → authoritative once, then caches the answer so later lookups are instant.
Why It Exists
People remember names; networks route IP addresses. DNS also lets the address behind a name change (new servers, failover, a CDN) without anyone updating bookmarks, which makes it a quiet but important tool for traffic management.
How It Works
browser: "IP of www.example.com?"
-> OS / browser cache (hit? done)
-> recursive resolver (ISP, 8.8.8.8, 1.1.1.1) - cache hit? done
-> root server: "ask the .com servers"
-> .com TLD server: "ask example.com's name servers"
-> authoritative NS: "www.example.com = 93.184.216.34, TTL 300"
<- resolver caches it for the TTL and answers the browser
Common record types: A (name → IPv4), AAAA (→ IPv6), CNAME (alias to another name), MX (mail servers), TXT (verification, SPF), NS (which servers are authoritative).
DNS in System Design
Global traffic routing: geo-DNS returns the IP of the nearest region; weighted records split traffic; health-checked records drop a failed region.
CDNs use DNS (often with anycast) to send users to a nearby edge.
TTL is the trade-off: long TTLs mean fewer lookups and faster page loads; short TTLs (30–60 s) mean faster failover because clients pick up changes sooner. Some clients ignore TTLs, so DNS failover is never instant.
Key Pointers
Name → IP, resolved through root → TLD → authoritative servers, cached at every level.
TTL controls how long answers are cached: speed vs agility.
DNS is a global load-balancing and failover tool, not just a lookup.
It is a dependency: use a redundant DNS provider, since a DNS outage takes your whole site down.
Follow-up Questions
You changed a DNS record but some users still hit the old server. Why?
Resolvers and clients cache the old answer until its TTL expires (some for longer). Lower the TTL well before a planned change, and keep the old server running until traffic drains.
Can DNS alone load-balance?
Roughly: returning several IPs spreads clients, but DNS can't see server load, caching makes changes slow, and a dead server stays in cached answers. Use it to pick a region, then a real load balancer inside the region.