Route 53 for Configuring Automatic Failover¶
Ensuring high availability and minimal downtime is critical for multi-region active-active abc applications and their components. Route 53 is a solution that provides predictable DNS records and the ability to perform automatic failover when issues occur, allowing you to configure automatic failover for applications hosted on multiple endpoints.
Through Route 53 health checks, you can monitor the availability of your endpoints and create failover resource record sets to direct traffic based on the health check status.
You can use one of the following Route 53 policies to set up DNS failover:
- Failover routing - Used to deploy into two regions.
- Weighted routing - Used to deploy into three or more regions.
Failover routing policy¶
The failover routing policy enables automatic redirection of traffic to a secondary resource if the primary resource becomes unavailable. This policy applies when you're deploying a service across two regions.
To implement the failover routing policy, the following are required:
- Primary and secondary Route 53 CNAME records: Route 53 records must be created for each regional resource's endpoint.
- DNS entry: A DNS entry with a non-region-specific name must be created and configured to route traffic to a regional endpoint.
Configure failover routing using a Route 53 stack¶
The following process assumes the target resources are deployed across two regions (us-east-1
and us-east-2
) and have corresponding regional domain names.
To configure the primary record:¶
- Create a CNAME record with a failover routing policy.
- Set a Time to Live (TTL) of 15 seconds.
- Configure the record to route traffic to the Route 53 alias record in
us-east-2
, pointing to the Application Load Balancer inus-east-2
. - Attach a health check to monitor availability. This health check should point to a CloudWatch alarm configured to monitor the ELB 5XXs metric for the ALB.
To configure the secondary record:¶
- Create an additional CNAME record with a failover routing policy.
- Set the TTL to 15 seconds.
- Configure the record to route traffic to a Route 53 alias record in
us-east-1
, pointing to the Application Load Balancer inus-east-1
.
Failover Routing Diagram
DNS Records
To test the failover scenario:¶
- Disable or stop the endpoint in the primary region (
us-east-2
), wait for the health check to detect the failure, then confirm the health check status changed. - Verify that the the traffic was rerouted to the secondary region (
us-east-1
).
Failover Health Check Diagram - Unhealthy
Failover Routing Diagram - Unhealthy
For more information, see How Amazon Route 53 determines whether a health check is healthy.
Weighted routing policy¶
The weighted routing policy allows traffic distribution across multiple endpoints based on assigned weights. This policy is applicable when deploying services across three regions.
To implement a weighted routing policy, the following is required:
-
Weighted Route 53 alias records - Create records pointing to the regional ALB records using a DNS entry with a non-region-specific name.
-
Creating weighted Route53 alias records pointing to the regional ALB records using a DNS entry with a non-region-specific name
Configure weighted routing using a Route 53 stack¶
The following process assumes the resources are deployed across three regions (us-east-1
, us-east-2
, and us-west-2
) and have corresponding Application Load Balancers.
To configure weighted records:¶
- Deploy a Route 53 stack in each region containing
A
records. - For each region, create an
A
record with the following configuration:- Region-specific Application Load Balancer - Use an alias that points to the respective Application Load Balancer in each region.
- Weighted routing policy - Attach a weighted routing policy with an assigned weight value. For example:
us-east-1
has weight value of 75us-east-2
has a weigh value of 130us-west-2
has a weight value 50
Weight values are used to determine the proportion of traffic that's routed to each region. For more guidance on choosing weight values, see AWS weighted routing.
Weighted Routing Diagram - Healthy
Weighted Records Example
To test the failover scenario:¶
- Disable or stop the endpoint in
us-east-2
, wait for the health check to detect the failure of endpoint inus-east-2
, then confirm the health check status changed. - Verify that traffic was rerouted to
us-east-1
andus-west-2
based on the assigned weights. In this scenario, slightly more traffic should be rerouted tous-east-1
thanus-west-2
.
Weighted Routing Diagram - Unhealthy
Note
A corresponding reference implementation demonstrates the deployment of the failover and weighted routing policies in this topic. This example uses an Application Load Balancer, but alias records can also point to the following endpoints: CloudFront distribution, Elastic Beanstalk environment, ELB classic load balancer, Amazon S3 bucket, or other Amazon Route 53 resource records set in the same hosted zone. Additionally, CNAME records can point to other endpoints, such as ElastiCache's replication group.
For more information, see Private Route 53 Failover Reference Implementation or visit the private-route53-failover-ref-imp repo.
Additional resources