DNS failover feature in Route53 is very useful during an outage of your application, as it’s automatically routes traffic to alternate locations where your application is operating properly.
Failover configuration can be either active-passive or active-active, if not you can also consider to go for a even more complex setup like active-active-passive or other mixed configurations with route53.
In this post, I’ll explain how you could build an active-active dns failover for your wep application spans over multiple aws regions.
At the end your setup should look like below.
As described in the diagram you will have 2 sets of app instances, each behind an elastic load balancer in two separate regions.
Active-Active failover is used when you want all of your app nodes in all regions to be available simultaneously, in this example both region 1 and region 2 are active. When one of the region becomes unavailable (This could happen due to application node crash, elb failures or even the region itself experiencing any problems), Route 53 can detect that it’s unhealthy and stop including it when responding to DNS queries.
I’ll be using the latency based failover for this setup. With latency-based routing, Amazon Route 53 can direct your users to the lowest-latency AWS endpoint available.
For demo purpose I’m going to deploy 2 demo web app in region us-east-1 and ap-southeast-1, each behind elb.
Ideally the deployed application should be identical in both regions, but I think I said its a demo ;)
When setting up DNS Failover for an ELB Endpoint, you simply set Evaluate Target Health to true. DNS Failover for ELB endpoints is available at no additional charge — you aren't charged for any health checks.
In Route 53, create 2 records sets for each ELB endpoints as described here.
For ELB in us-east-1 (Region 1)
For ELB in ap-southeast-1 (Region 2)
Now when you access your application, you should get your resolved DNS based on the lowest latency. Since I’m living closer to ap-southeast-1, mine looks like this.
Now it’s time to see, if the failover works for real.
Let’s go ahead and stop the instances in ap-southeast-1. The ELB in ap-southeast-1 region now marks it instances as “Out of Service” and Route53 will begin to route traffic to the other healthy region — which is us-east-1.
This is a basic example of how you can use the Route53 DNS failover to detects the failures and route the traffic away from failed endpoint. Route53 evaluate the health of the load balancer and the health of the EC2 instances running behind in it.
If you want to try more complex scenario, check out the docs