Tweaking the TTL to reduce downtime after a website migration

Posted at October 30, 2015 at 1:45 pm by admin

ttlWebsite migrations are succeeded by DNS changes. A well planned change minimizes downtime and DNS propagation delays that follows every migration. You don’t want to create a panic among your customers when their emails are lost during the switch or if their websites are inaccessible from their location.

It is always a best practice to maintain the copy of all migrated accounts at the old host for a few more days so that the websites remain online for customers whose web/mail requests are still served by the old server. Their ISP’s caching DNS servers/resolvers still serve cached DNS information to clients even after you have pointed the domain to a location.

The problem with DNS caching is that it is the primary cause for delay in propagation of the DNS changes (Address records, mail exchange records etc.) you made after the migration. This is due to the fact that most of the DNS traffic is eased with DNS caching where your resolver/caching DNS caches DNS information for a predefined time. The entity that determines this time is TTL( Time to live). By default the TTL values for most resource records are 86400 seconds (24 hours). Any resolver that queries for the A record of your domain will cache that info for 24 hours.

To solve this problem to an extent, you can lower the TTL values of the resource records (MX, A) before you change the IP address. We assume that you have root/sudo access to the authoritative nameserver.

Login to the DNS server and all you have to do is edit the zone file in the authoritative nameserver of the domain (You may use DNS zone editor in cPanel if the service is running on a cPanel server)

Lets open xyz.info’s zone file using vi editor

vi /var/named/xyz.info

These are the first few lines of the zone file, you can see the first line $TTL that defines the default TTL for all existing records to 86400 seconds.

———————————————–

$TTL 86400

xyz.info.       IN    SOA  ns1.example.info. admin.xyz.com. (

2012080907      ; Serial

10800           ; Refresh

3600            ; Retry

604800          ; Expire

300             ; Negative Response TTL

)

———————————————–

We’ll change this to 300 seconds (5 minutes)

$TTL 300

We’ll increment the serial number from 2012080907 to 2012080908 so that the DNS server can verify the contents of the zone file.

Now reload the DNS service
/etc/init.d/named reload

Reloading named:              [  OK  ]

After this we will wait for the last TTL amount of time (24 hours) to make sure that the caching nameservers all around the world that has previously queried and cached this domain’s DNS information has purged the information. Once that time has passed we’ll switch the A record to the new server’s IP. I wouldn’t say this is 100% foolproof as there are caching nameservers which enforces their own TTL values and web browsers too cache DNS info for a default amount of time.

Note:- Make sure you revert the TTL value change later , a low TTL value will lead to an increase in DNS traffic.

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply