map / networking / dns

Networking · principle 2 of 6

DNS resolution

DNS is a cached, hierarchical lookup; most DNS incidents are really caching (TTL) incidents.

01 · Why it’s true

Names are resolved by asking a chain of servers. Your machine asks a recursive resolver; if the resolver has no cached answer, it asks a root server, which points it to the servers for the top-level domain (like .com), which point it to the domain’s authoritative servers, which return the answer.

Every answer carries a TTL (time to live) that tells resolvers how long they may cache it. Caching is what makes DNS fast and scalable — and it’s why DNS changes don’t take effect instantly everywhere, and why a bad record can linger after you’ve fixed it.

02 · Picture it

Your machineasks oneresolver, waitsRecursiveresolverdoes thelegwork, cachesanswersRoot serverspoint to eachTLD.com serverspoint to eachdomain’sserversAuthoritativeholdsexample.com’srecordsCold cache: the full walk, 8 steps1www.example.com?2www.example.com?3ask .com4www.example.com?5ask ns1.example.com6www.example.com?7203.0.113.7 · TTL 3008203.0.113.7 (now cached)not contactedReused until the 300 s TTL runs out, then thefull walk happens again.Warm cache: 2 steps, answered from memory1www.example.com?2203.0.113.7 (cache hit)requestresponseskipped (cache hit)TTLs are why DNS is fast — and why a changed record keeps serving the old answer untilcached copies expire.
WHO’S INVOLVEDYour machineasks one resolver, waitsRecursive resolverdoes the legwork, caches answersRoot serverspoint to each TLD.com serverspoint to each domain’s serversAuthoritativeholds example.com’s recordsCold cache: the full walk, 8 steps1Your machine → Recursive resolverwww.example.com?2Recursive resolver → Root serverswww.example.com?3Root servers → Recursive resolverask .com4Recursive resolver → .com serverswww.example.com?5.com servers → Recursive resolverask ns1.example.com6Recursive resolver → Authoritativewww.example.com?7Authoritative → Recursive resolver203.0.113.7 · TTL 3008Recursive resolver → Your machine203.0.113.7 (now cached)Warm cache: 2 steps, answered frommemory1Your machine → Recursive resolverwww.example.com?2Recursive resolver → Your machine203.0.113.7 (cache hit)Reused until the 300 s TTL runs out,then the full walk happens again.requestresponseTTLs are why DNS is fast — and why achanged record keeps serving the oldanswer until cached copies expire.
A cache miss walks the hierarchy in 8 steps; within the TTL, the resolver answers in 2.

03 · In the interview

  • Explaining why a DNS change “didn’t work” for some users: they still hold a cached answer.
  • Choosing TTLs: short for records you may need to change quickly, longer for stable ones.
  • Treating DNS as a dependency of almost everything — and a common outage cause.

04 · Practice question

“We moved our service to a new IP an hour ago, but some users still reach the old one. Why, and what would you do?”

A strong answer covers

  1. Resolvers cache the old record until its TTL expires; some clients and runtimes also cache by their own rules.
  2. Check the TTL that was published before the change — that’s the minimum wait for well-behaved resolvers.
  3. Keep the old endpoint serving (or forwarding) until its traffic drains.
  4. Next time: lower the TTL well before a planned move, then raise it again afterwards.