OS, networking and concurrency · Question 32 of 50

How does DNS resolution work?

What they're checking

Caching, TTLs, and what "propagation" really is.

The answer

To turn api.example.com into an IP address, the browser and the operating system check their caches. Then a recursive resolver (your ISP's, or 8.8.8.8) checks its own cache and, if it must, asks a root server, which points to the .com servers; the .com server points to example.com's name servers; and the authoritative name server answers with the record: A for IPv4, AAAA for IPv6, CNAME for an alias.

Every answer carries a TTL, and caches keep it that long, which is why a DNS change takes a while to reach everyone.

The picture

browser / OS cache ─ miss ─▶ resolver ─▶ root: "ask .com"
                              │ ─▶ .com: "ask ns1.example.com"
                              │ ─▶ authoritative: "A 93.184.216.34, TTL 300"
                              └─ caches it ─▶ browser
The follow-up they'll ask

How do you move a site to a new IP with no downtime?

Show the answer

Lower the TTL a day before, switch the record, keep the old server up until the old TTL has passed, then raise the TTL again.

Your progress stays on this device.