How to configure DNS load balancing and failover using AWS Route 53 – CloudSavvy IT

AWS Logo

Load balancing is the concept of distributing application or network load between two or more servers, resulting in better performance and longer availability. AWS load balancers cost money to run, but you can get the same effect for free using Route 53.

How does DNS load balancing work?

With a normal load balancer, like the one from AWS Application Load Balancer, you direct all traffic to the load balancer, and it handles the work of routing traffic to your instances. In reality, all AWS load balancers are instances running a service like HAProxy and handling a high volume of traffic.

RELATED: How to configure a HAProxy load balancer

The idea behind DNS load balancing is quite simple. Even with the standard load balancer, the user must perform a DNS lookup to find out where to send requests to your website. However, DNS does not need to be static, and this is the idea that the AWS Route 53 DNS service has implemented. Once configured, every time User A requests the site, it will be sent to Server 1, and when User B requests the Site, Route 53 will send them to Server 2 instead.

User A requests site, is sent to server 1. User B requests site, Route 53 sends to server 2 i

This can optionally be configured according to a different model: failover. If your application can run on a single server, but you need 100% availability, Route 53 can redirect traffic to a standby instance whenever the primary instance becomes overloaded or unavailable.

If you want to configure one of these templates, Route 53 makes it easy for you. If you’re not already using Route 53 and want to switch, you can read our guide on transferring your domain name to this one.

RELATED: How to transfer a domain name to AWS Route 53

Route 53 configuration

Connect to the Route 53 management console, then select “Health Checks” from the sidebar and create a new health check. These will be used to route traffic from unhealthy instances in the scaling group. These cost $ 0.50 per month each, but they are optional.

To select "Health checks," create a new health check.

Health checks have a few options, but most of the time you just give Route 53 an endpoint to watch out for. You can use either an IP address or a domain name, but if you are monitoring the health of an individual server, you will want to use the Elastic IP address for that server.

Configure health check

You’ll want to repeat this process for all of your servers, creating a health check for each.

Click “Hosted Zones” in the sidebar and display the hosted zone for your domain. “Create” or modify a new A record, and enter the IP address of one of your servers. You can also just use aliases, which dynamically map to an AWS resource.

If you set the routing policy to “Weighted”, you can assign a weight to this record. By giving a weight of 1 to several A records, Route 53 will also choose between them. For “Set ID”, enter something unique that is the same for all records in that weight group.

Set the routing policy to "Weighted," assign a weight to this record.  In "Define the identifier," enter something unique and the same for all records in that weight group.

Below, click “Yes” for “Associate with health check” and select the health check for this server. If the health check fails, this record will not be selected.

    Click on "Yes" for "Associated with Health Check," select server status check

Repeat this process for each server.

If you want to configure failover, set the routing policy to “Failover” instead and select “Primary” or “Secondary”, depending on the server. You’ll want to tie this to a health check as well.

Configure failover.

After you’ve saved the recordings, Route 53 should start balancing the traffic.

Leave a Reply

Your email address will not be published. Required fields are marked *