AWS Route53: DNS Failover now with Elastic Load Balancer Support

by Andrii Kozhokary

DNS Failover is a great and handy feature for sure, but those who hosted large projects with ELB on AWS didn't notice any difference. If a failover does not support ELB, this function is absolutely useless for me, personally.

Finally, the day when we can use Route53 with ELB has come. By setting up the rooting policy as Failover and connecting the record to ELB, we enable the ELB automatic monitoring option. The record type will be automatically switched from Primary to Secondary in the following situations:

  • ELB fails or is unavailable
  • There are no healthy instances under ELB

Route53 now provides the possibility to switch automatically to a new region if the current one fails completely.

In this article, I will share my experience with testing the new functionality.

So, for my tests, I prepared two ELBs, each with an instance under it. To distinguish between the balancers, I installed Apache on one, and nginx on the other.

Route53 was used with the following settings:

As you can see, one record is Primary, and the other is Secondary.

In its usual state, the test.kozhokaru.com domain displays the Apache page that is our running application:

The domain is pointed:

$ host test.kozhokaru.com
test.kozhokaru.com has address 23.21.77.253

For testing purposes, we should go to the host and disable Apache in order to imitate application failure. Then we should go to our webpage to see what's going on there:

In approximately 40 seconds, the ELB realizes that its instance is not performing well:

Two minutes later we are directed to the failover page:

The IP address has changed:

$ host test.kozhokaru.com
test.kozhokaru.com has address 107.21.245.152

We can return everything to the previous state by running Apache on the first host. The host will be identified as healthy after some time depending on the ELB health check:

In 1 minute 40 seconds the domain was back on the main ELB.The IP address has changed back:

$ host test.kozhokaru.com
test.kozhokaru.com has address 23.21.77.253

Conclusions

An automatic domain failover takes about two minutes, the same time is required to return to the previous state. Now, we have a wonderful function that will definitely help us create a distributed system of high availability.