Understanding TTL (Time To Live) in DNS – Route 53
What is TTL?
TTL (Time To Live) is a crucial setting in DNS records that determines how long a DNS response is cached by clients or recursive resolvers. When a client queries a DNS record (e.g., myapp.example.com), it receives an IP address along with a TTL value, which dictates how long the client should cache this response before making another DNS request.
TTL in Action
- Suppose a client queries Route 53 for
myapp.example.com.
- Route 53 responds with an A record containing an IP address and a TTL of 300 seconds.
- The client caches this record for 300 seconds and does not make further DNS queries until this period expires.
- This reduces DNS traffic and improves efficiency, as repetitive requests are avoided within the TTL period.
Impact of High vs. Low TTL
| TTL Value |
Advantages |
Disadvantages |
| High TTL (e.g., 24 hours) |
Less DNS traffic → Cost savings |
Updates take longer to propagate |
| Low TTL (e.g., 60 seconds) |
Faster updates, more flexibility |
Higher DNS traffic → Increased costs |
TTL Change Strategy
If you plan to modify a DNS record:
- Lower the TTL (e.g., from 24 hours to 60 seconds).
- Wait for the old TTL period to expire so all clients receive the new, lower TTL.
- Update the DNS record (e.g., change the IP address).
- Increase the TTL again to optimize performance and reduce costs.
TTL in Practice (AWS Route 53 Console)
- Creating a New Record
- Domain:
demo.stephanetheteacher.com
- Record Type: A Record
- Assigned IP: EC2 instance in eu-central-1
- TTL: 120 seconds (2 minutes)
- Verifying the DNS Resolution
- Using Google Chrome to access
demo.stephanetheteacher.com → Successfully resolves to the correct IP.
- Running
nslookup and dig in CloudShell:
dig demo.stephanetheteacher.com
- The response shows the current TTL countdown.
- Updating the DNS Record
- Change the IP to another EC2 instance in
ap-southeast-1.
- Since the old TTL is still valid, the cached value remains unchanged for the remaining time.
- After waiting for the TTL to expire, running
dig again shows the new IP.