Sub topic 8
Redirecting traffic with Route 53 and Global Accelerator
This chapter assumes you know how DNS records, TTLs, and Application Load Balancers (ALBs) work, and that you can read AWS CLI JSON. A recovery Region is only useful if users reach it. Two services handle that: Amazon Route 53 (DNS-based) and AWS Global Accelerator (IP-based).
DNS failover with Route 53
Route 53 failover routing returns one of two records. It answers with the primary while its health check passes. When the check fails, it answers with the secondary.
- A Route 53 health check probes the primary endpoint from several locations. It marks the endpoint unhealthy after a set number of consecutive failures.
- The failover record named
PRIMARYis withdrawn from answers. - Resolvers receive the
SECONDARYrecord, which points at the DR Region.
The change batch below creates both records. Apply it with aws route53 change-resource-record-sets --hosted-zone-id <ID> --change-batch file://failover.json.
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "app.example.com",
"Type": "CNAME",
"SetIdentifier": "primary",
"Failover": "PRIMARY",
"TTL": 60,
"HealthCheckId": "REPLACE_WITH_HEALTH_CHECK_ID",
"ResourceRecords": [
{ "Value": "primary-alb.us-east-1.elb.amazonaws.com" }
]
}
},
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "app.example.com",
"Type": "CNAME",
"SetIdentifier": "secondary",
"Failover": "SECONDARY",
"TTL": 60,
"ResourceRecords": [
{ "Value": "dr-alb.us-west-2.elb.amazonaws.com" }
]
}
}
]
}Failover time is roughly the health check detection time plus the record TTL. A 30-second check interval with a failure threshold of 3 takes about 90 seconds to detect an outage. A 60-second TTL then adds up to a minute for cached answers to expire. Some resolvers and clients ignore low TTLs, so a few users may keep reaching the failed Region longer.
Static IPs with Global Accelerator
Global Accelerator gives your application two static anycast IP addresses. Traffic enters the AWS network at the nearest edge location and is forwarded to healthy endpoints, such as ALBs, in your chosen Regions. Each Region is an endpoint group with a traffic dial from 0 to 100.
Because clients keep the same IP addresses, no DNS cache has to expire. Global Accelerator reroutes within seconds of a failed health check. To drain a Region by hand during a planned failover, set its dial to zero. The Global Accelerator API is served from us-west-2.
aws globalaccelerator update-endpoint-group \
--region us-west-2 \
--endpoint-group-arn REPLACE_WITH_ENDPOINT_GROUP_ARN \
--traffic-dial-percentage 0Choosing between them
| Aspect | Route 53 failover | Global Accelerator |
|---|---|---|
| Mechanism | DNS answers change | Anycast IPs, rerouted at the edge |
| Client caching | TTL and resolver behavior matter | Not affected |
| Typical switch time | Check time plus TTL | Seconds |
| Static IPs for allow-lists | No | Yes |
| Cost | Low | Hourly fee plus data transfer premium |
Route 53 is enough for backup and restore and pilot light, where recovery already takes minutes. Global Accelerator suits warm standby and active/active designs with tight recovery time objectives, or clients that pin IP addresses.
Common errors
- Health check on the wrong thing. Probing a static page can pass while the database is down. Point the check at an endpoint that exercises dependencies, or use a calculated or CloudWatch alarm health check.
- Long TTLs. A 300-second TTL delays failover by up to five minutes after detection.
- Untested DR endpoint. The secondary record has no health check here, so Route 53 returns it even if it is broken. Test it before you need it.
Exercise
Your DR plan needs clients with hard-coded IP allow-lists to reach the DR Region within seconds of a failure. Which service do you pick, and why does a 60-second Route 53 TTL fall short?
Show answer
Pick Global Accelerator. It provides static anycast IPs and reroutes at the edge in seconds. With Route 53, failover time is the health check detection time plus the TTL, and clients with hard-coded IPs do not follow DNS changes at all.