Opscraft
DNS TTL & caching · Lesson 8 of 8 · 3 min read

Interview questions and model answers

"What is DNS TTL and who controls it?"

It's the number of seconds a resolver or client may cache a DNS answer before asking again, set per record set by the zone owner on the authoritative servers. Caches count it down; when it hits zero they fetch a fresh copy. Resolvers can cap it, and some applications ignore it.

"Why does DNS propagation take up to 48 hours?"

There's no push — resolvers keep cached answers until their TTL expires. Long TTLs on the old record mean long waits. For name server changes, the parent TLD's NS records typically have a two-day TTL that you can't change, so some resolvers keep using the old provider for up to 48 hours. That's why you keep both providers serving identical data during a migration.

"You need to move a record to a new IP tomorrow. How do you prepare?"

At least one current-TTL period before — ideally the day before — lower the TTL to around 60 seconds. Make the change at cutover, keep the old endpoint running until its traffic drains, watch for clients that ignore TTL, then raise the TTL again. If the old TTL was a day, the lowering has to happen a day in advance.

"We changed the record ten minutes ago but some users still hit the old IP. The old TTL was 3600. Is something wrong?"

No, that's expected — resolvers that cached the record just before the change can serve it for up to an hour. Some clients may take even longer if they ignore TTL. I'd keep the old endpoint serving, and next time pre-lower the TTL.

"You created a record, but it still returns NXDOMAIN for some people. Why?"

Negative caching — someone queried the name before it existed, and resolvers cached the NXDOMAIN for the negative TTL from the SOA, about 15 minutes on Route 53 by default. Wait it out or flush the resolvers we control; avoid querying names before creating them.

"How does TTL affect failover?"

Route 53 flips the answer after health checks fail, but clients switch only when their cached answer expires — up to the TTL later. So failover records use ~60 s TTLs, health checks with fast intervals, and clients that retry and re-resolve. For faster, cache-independent failover, switch at the load balancer or use Global Accelerator.

"A Java service keeps calling an old load balancer IP after the ALB scaled. Fix?"

The JVM is caching DNS too long — networkaddress.cache.ttl is probably -1 or very high. Set it to around 60 seconds, and make sure connection pools have a maximum lifetime so long-lived connections re-resolve. Also make sure the record is an alias or CNAME to the ALB name, never hardcoded IPs.

"Why can't you set a custom TTL on a Route 53 alias to an ALB?"

Because Route 53 answers alias queries with the target's current records and TTL so it can follow the load balancer's IP changes as it scales; for ELB that's 60 seconds. It's also free to query, unlike a CNAME.