intermediate
DNS resolution
Explain recursive resolution, authoritative records, TTLs, caching, CNAME chains, propagation expectations, and DNS failure symptoms.
DNS maps hostnames to records (A, AAAA, CNAME, MX, TXT, SRV). Resolution is recursive from the client through resolvers to authoritative nameservers. TTL controls cache lifetime; low TTL speeds propagation but increases lookup load and latency variance.
App → OS stub resolver → ISP/recursive resolver → root → TLD → authoritative NS → answer
Node services resolve DNS on every new connection unless you cache at the agent layer (`lookup` options, custom agents, or service mesh sidecars). CNAME chains add round trips. NXDOMAIN and SERVFAIL surface as connection errors that look like application bugs.
On interviews: diagnose "works in browser, fails in Node" as DNS or TLS trust differences; explain TTL trade-offs during migrations; describe negative caching and stale records.
Common pitfalls: hard-coding IPs that change; ignoring IPv6 AAAA when only A is tested; assuming instant global propagation after a record change.
The trade-off is cache freshness versus lookup cost and migration safety.
Checklist:
- Trace recursive resolution steps.
- Explain TTL, CNAME, and authoritative vs recursive.
- Name symptoms of DNS failure in Node logs.
- Plan cutovers with lowered TTL ahead of time.