We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

DNS TTL and Caching

When you update a DNS record, the change doesn't appear everywhere immediately. DNS is eventually consistent and heavily cached.

"Eventually consistent" means changes are applied, but not everywhere at once. It takes time to propagate.

When creating DNS records, you'll notice a field called TTL (Time To Live). This tells resolvers how often to re-check a record. If our records change often, clients need a lower TTL.

The tradeoff is always the same: lower TTL means faster updates but more queries. Higher TTL means slower updates but fewer queries.

Cost check: Handling more queries can increase costs for public DNS. But Route 53 doesn't charge for queries to our private hosted zone, so lowering its TTL won't impact costs.

When a cached record expires, the resolver has to look it up again. That lookup adds latency, so a lower TTL can mean more time spent waiting on DNS.

When you update a DNS record in Route 53:

  1. Route 53 immediately has the new record.
  2. Clients won't ask Route 53 again until the TTL expires.
  3. Eventually, all caches expire and everyone sees the new record.

This is part of why the meme "It's always DNS" exists. If you submit a typo in your DNS record, you'll have to wait for the TTL to expire before your customers start getting the correct address. I once watched a team spend hours debugging why their new server wasn't getting traffic, only to realize they had a typo in the IP address, and even after fixing it, they still had to wait for TTL expiry.