5

I need to replace an aging webserver which runs a busy website. I have the new hardware up and running, all software is installed. There's only one problem left where I'm looking for a solution:

When I change the A record for the domain in DNS, it takes a while for the change to propagate through the internet due to DNS caching. During that time, some users will hit the new server, and some will hit the old one, leading to data inconsistencies because there are now two databases. How can I switch everyone over instantly? I do not run the DNS server and cannot change anything but the A and CNAME records, but I could setup my own if that helps.

I can probably have an hour or two of downtime when moving overnight.

Thanks, Simon

edit: Thank you for all your answers. I'm accepting SmallClanger's answer because it's a viable solution, and I'm upvoting Brian because his answer gave me a new idea: Follow SmallClanger's solution up to the database migration, and then replace the old apache with an HTTP proxy which proxies all requests to the new server. I'd configure the proxy to address the new server by IP address, and it does not involve a temporary subdomain which might (despite the 302 code) end up in some bookmark directory, social network or browser cache.

2
  • the way the questions is formulated suggests that the old and the new server are not 'side-by-side' - but for clarification: you really need to switch DNS entries rather than re-assigning the old server's IP address to the new one?
    – iiegn
    Dec 1, 2010 at 15:18
  • These are two dedicated servers with two different providers, so no, they are not side-by-side and I cannot take IP addresses with me.
    – Simon
    Dec 1, 2010 at 16:02

7 Answers 7

2

The fundamental problem you have is of maintaining database consistency during the switch. To have zero downtime, you'll have no choice but to set the two servers up in an active/active cluster. (even assuming, for the moment, that the cluster setup would involve no downtime itself, which is a bit of a stretch.).

Given that you can't change the TTL, you best step is to minimise downtime:

  • Set the new site up on a second domain name (eg: www2.example.com), but make it answer to www.example.com, too. Point the DNS for www2 at the new server only.
  • Have the site files replicated and locked down from edits on both sides.
  • Then in an advertised maintenance window, replace the live site with a 'down for upgrades' notice.
  • Sync or copy the database across as required, and then start the new server.
  • Then (and only then) make your DNS changes to the www record.
  • Replace the old site config with a simple 302 redirect to www2.example.com
  • Wait for the full TTL to expire (and then a bit) before taking the old server down.

This will make sure all traffic goes to the new site during the DNS propagation, regardless of which server they go to initially, though it assumes your site is capable of being served from multiple domain names at the same time.

For a single-server LAMP stack (if that's what you've got), then this is your route to minimal (but not zero) downtime.

3

You could configure the old web server to redirect all requests to the new IP. This can be done with mod_rewrite in apache.

0

You could lower the TTL of your zone one or two days before the migration to a small value. After you've changed the A resource record you can raise the TTL again to its old value.

0

You have to migrate first all data files on the new server (apache and mysql files) . After that when you have 2 houres to stop server you can synchronize all datafiles with rsync. LIke that rsync -avz /var/www/sites (old-server) user@hosts2:/var/www/sites (new-servers) . And export import all datafiles on sql server from server 1 to new server . Then swich server 2

and stop old server if you have some problem start again server 1 and repear errors on newserver .

But before you start new server check for errors make own test.

0

lower the TTL, and put up under maintance sign on old page?

0

I thing TTL is bad idea. Becouse if old server is alive , some user meybe will connect on old server and another users meybe will use new server. If you really have 2 hours use syn and export inport all from sql to sql then swich on new server Am sure all will be fine with mu solutions

0

You could use the old server IP for your new server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .