DNS
DNS TTL & caching
TTL — time to live — is the number that tells every DNS cache how long it may keep an answer. It's why "DNS propagation takes up to 48 hours", why a failover can take five minutes to reach users, why you lower TTLs before a migration, and why a Java service keeps calling an old load balancer IP. Senior engineers are expected to plan DNS changes around TTLs, design failover with realistic switch times, and know every layer that caches DNS answers — including the ones that ignore TTL entirely.
After this topic you can
- Explain caching and TTLs at every level
- Plan a DNS change or migration with low TTLs
- Debug "some users still see the old IP"
Lessons
-
1What a TTL is
- A per-record cache lifetime
- Reading TTLs with dig
- Who sets and who obeys
- 2The cache hierarchy
- 3Negative caching
-
4Propagation and planning changes
- "Propagation" is really expiry
- A migration timeline
- Name server (delegation) changes
- Verifying propagation
-
5Choosing TTLs
- Trade-offs
- Sensible defaults
- Cost on Route 53
-
6TTL, failover and load balancing on AWS
- DNS failover is bounded by TTL
- Why ELB IPs change and why aliases matter
- DNS switch vs load balancer switch
- Lessons from incidents
-
7Application-level DNS caching
- The JVM
- Other runtimes
- Connection pools pin IPs regardless of DNS
- Mobile and IoT clients
-
8Interview questions and model answers
- "What is DNS TTL and who controls it?"
- "Why does DNS propagation take up to 48 hours?"
- "You need to move a record to a new IP tomorrow. How do you prepare?"
- "We changed the record ten minutes ago but some users still hit the old IP. The old TTL was 3600. Is something wrong?"
- "You created a record, but it still returns NXDOMAIN for some people. Why?"
- "How does TTL affect failover?"
- "A Java service keeps calling an old load balancer IP after the ALB scaled. Fix?"
- "Why can't you set a custom TTL on a Route 53 alias to an ALB?"