← System Design
Core Concepts

What is DNS?

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.

Resolving www.example.comBrowserRecursive resolver(ISP / 1.1.1.1)1. Root server2. .com TLD server3. Authoritativename serverlookupIPanswer (cached for TTL)
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

Key Pointers

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.

Related