Using DNS to push out new versions of web application

Amazon has support for the exact feature you should use to switch live service from one instance to another. It is called "Elastic IP Address" and is described here:

http://aws.amazon.com/articles/1346

The initial steps involved are:

  1. Allocate an Elastic IP address.

  2. Associate the Elastic IP address with your instance.

  3. Set your DNS to permanently point to the Elastic IP Address (so there is no DNS caching/propagation delay).

Steps 1 and 2 can be done with the EC2 command line or the web console. Step 3 is done with your usual DNS service.

When you are ready to switch to a different EC2 instance, simply change the Elastic IP Address to be associated with the new instance. It takes some seconds for the change to filter through the EC2 network devices and then you're back in business.

It's also possible to do this with an Elastic Load Balancer, but for single instances Elastic IP Address is probably simpler.

Elastic IP Addresses can also be used to resolve to the (changing) internal IP address of the current instance using a CNAME trick. Here's an article I wrote about that:

Using Elastic IP to Identify Internal Instances on Amazon EC2
http://alestic.com/2009/06/ec2-elastic-ip-internal


It can work, however you need to remember that DNS takes time to propagate. Plus, users may be using their local DNS cache. You can do it, but temporarily take down the front page of the "old version" server and set up a redirect to go to the "new" server's IP. That should cover the corner cases.