TTL Setting Rules
Overview
TTL specifies how long a local DNS server (Local DNS) can cache record sets. It is measured in seconds. Common TTL values include 300 seconds (5 minutes), 3,600 seconds (1 hour), and 86,400 seconds (24 hours). The default TTL value for Huawei Cloud DNS is 300 seconds.
Effective Mechanism
When receiving resolution requests for a domain name, the local DNS server asks the authoritative DNS server for the required DNS record set, and then caches the record set for a period of time, as defined by the TTL value specified in the record set.
- During this TTL period, if the local DNS server receives resolution requests for this domain name again, it will not request the record set from the authoritative DNS server, but directly returns the cached record set.
- When the TTL expires, the local DNS server clears the cached record set. If the local DNS server receives new resolution requests for the domain name, it forwards the new resolution requests to the authoritative DNS server to obtain the latest record set and caches the record set.
Scenarios
When setting the TTL value, you need to balance record set stability with update frequency. Set a long TTL for stable record sets and a short TTL for frequently changing record sets. Pay attention to the following:
- A balance between load and response: When changing the TTL value, you need to balance the network load and response speed. A large TTL can delay updates, while a small TTL increases load.
- Network environment evaluation: When changing the TTL value, you need to consider both the network stability and packet loss rate to ensure that the changed TTL value is suitable for the actual environment.
- Monitoring and testing: After changing the TTL value, you need to monitor and test its impact to confirm it delivers the expected behavior and adjust it further if necessary.
- Change management: Before changing a DNS record set, such as changing the server IP address, set a small TTL value to allow you to get fresh IP addresses more often. Once the change is applied, you can change the TTL value to the original one.
| TTL Setting | Scenarios | Description |
|---|---|---|
| Increasing the TTL value | Reducing network traffic | A large TTL value allows DNS record sets to be cached on the client or server for a longer period. This reduces the number of queries to the DNS server and reduces the network load. |
| Faster response | A large TTL value allows IP packets to remain on the network longer. This reduces the number of requests and prevents network congestion. | |
| Stable network | On a stable network with low packet loss, a large TTL value can improve data transmission efficiency by reducing unnecessary retransmissions. | |
| Decreasing the TTL value | Quick update |
|
| Testing and diagnosis | In network tests, a small TTL value causes packets not stay on the network for a long time. This allows you to quickly identify, trace, analyze, and troubleshoot network issues. | |
| Dynamic network environment | A small TTL value reduces the impact of outdated routes in dynamic networks. This improves overall adaptability and response speed as routes change | |
| Reducing network congestion | A small TTL value prevents packets from lingering on the network, reducing the chance of congestion, especially in bandwidth-limited environments. |
Configuration Method
- Method 1: Configure the TTL value when adding a record set. For details, see Adding Record Sets for a Public Zone.
- Method 2: Modify the TTL value of an existing record set. For details, see Modifying a Record Set.
Common Issues
- The number of authoritative DNS queries increases sharply, the resolution delay increases, and service scheduling frequently fluctuates.
Cause: The TTL value of the A or CNAME record set is too small. As a result, the recursive DNS cache expires quickly, causing repeated queries.
Solution: For stable services, set the TTL value to 3,600 to 86,400 seconds. Use a TTL value of 300 seconds only for temporary debugging, and increase it again once debugging is complete.
- After the IP address or CNAME record set of a domain name is changed, users continue accessing the old address for an extended period, and the resolution takes a long time to take effect.
Cause: The TTL value of the original record set is too large, and the recursive DNS caches in different regions remain valid.
Solution: Before making the change, lower the TTL value to 300 seconds and wait for existing caches to expire. After updating the DNS record set and the service stabilizes, restore the original TTL value. Users can manually refresh the DNS cache on their devices.
- The TTL of the domain name has been applied, but the local device still resolves the old IP address.
Cause: The operating system has a local DNS cache, and some carriers use custom recursive DNS cache policies, ignoring the TTL value configured for the domain name.
Solution: Run the corresponding command on the client to clear the local DNS cache. Check whether the issue is caused by the carrier's cache by switching to a public DNS server.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot