How to Move Website Hosting without Downtime
There are occasions when migrating a website is unavoidable – the site may have outgrown its existing hosting or the hosting company might have become unreliable. A common issue in this situation is the time taken for a domain name to fully switch IP addresses. Here we take a look at how to minimise this transition time.
Moving a static site or one with infrequently updated content is fairly straightforward: duplicate the site on the new host, update the DNS, wait for all DNS servers to update then switch off the old server. However, this tried and tested method doesn’t work so well for a transactional site or one with user-generated content – here it is critical that data stays consistent so we can’t tolerate a situation where we don’t know which version of the site a user will be directed to.
In this case, the old host will need to display a ‘503 temporarily unavailable’ page as soon as the DNS change is made, in order to prevent database or filesystem changes being made, and to ensure data integrity. For a commercial site, a potential 48-hour period of unavailability for some customers (dependent on DNS caching) will not be acceptable. Fortunately, this transition time can be reduced using something known as the TTL (time to live). TTL instructs DNS servers how long they may cache DNS records for and by setting this to a lower value we can ensure faster propagation (a drawback is greater server load and increased access times so this setting should be restored when the process is complete).
Step 1: Duplicate your Site
Set up your website on the new server and copy the existing data. You can check that all is in order by temporarily adding your website’s new IP address to your hosts file (e.g. c:windowssystem32driversetchosts on windows) and visiting the site in your browser.
Step 2: Prepare for DNS change
Firstly you will need to make sure that your DNS provider allows the TTL to be adjusted on A records – some do not. If yours doesn’t, you may be able to switch provider. In this case you’ll need to duplicate all DNS settings with the new provider, switch the nameservers at your registrar, then wait 48 hours to be sure that all clients are pointing at the new servers.
Plan a time when you will make the migration. At least 48 hours before this time, update the TTL on the record you wish to move to 3600 seconds (1 hour). After 2 days you can assume that all DNS servers will now be caching your IP for only one hour. Two hours before migration, visit your domain name control panel again and adjust the TTL down to 300 (5 mins). Wait another two hours.
Step 3: Make the switch
The quicker you can carry out these steps, the better!
- Switch your site to maintenance mode (replace with a 503 page) on the old server.
- Perform final synchronisation of filesystem and database, to ensure that everything gets copied.
- Update your DNS to point to the new server’s IP address.
Step 4: Tidy up
After you’re confident that the DNS has fully transitioned (which should only take 10 minutes) you can switch off the old server and reinstate the TTL to its original value.