Sub topic 8
Redirecting traffic with Route 53 and Global Accelerator
This chapter assumes you know how DNS records, TTLs, and load balancers work. It also assumes you have read the earlier chapters on pilot light and warm standby. Having a recovery Region is only half of disaster recovery (DR). Users must also reach it, quickly and without someone typing commands during an outage. AWS offers two main tools for that: Amazon Route 53 (DNS-based) and AWS Global Accelerator (IP-based).
Two ways to move traffic
Route 53 changes the answer a DNS query returns. Clients that ask for app.example.com receive the address of the primary Region or the DR Region, depending on health. The answer is cached by resolvers and clients, so the switch is only as fast as those caches expire.
Global Accelerator gives your application two static anycast IP addresses. Clients connect to the nearest AWS edge location, and AWS forwards the traffic over its own network to a healthy Regional endpoint. The client's address never changes, so no DNS cache has to expire.
| Aspect | Route 53 failover | Global Accelerator |
|---|---|---|
| Mechanism | DNS answers change | Edge routing to endpoint groups |
| Client-side caching | Yes, TTL and resolver behavior matter | No DNS change, the static IPs stay |
| Typical switch time | Health check detection plus TTL | Health check detection only |
| Endpoints | Any public address or alias target | ALB, NLB, EC2 instance, Elastic IP |
| Protocols | Any, because it is DNS | TCP and UDP |
| Manual control | Edit records or use routing controls | Set the traffic dial per Region |
| Extra cost | Per hosted zone, query, and health check | Hourly fee plus a data transfer premium |
The tools are not exclusive. Some teams put Global Accelerator in front of the application and use Route 53 health checks for alerting and for other records.
Route 53 failover routing
Failover routing uses a pair of records with the same name. The primary record answers while its health check passes. When the check fails, Route 53 answers with the secondary record.
Health checks
A health check is a probe run by Route 53 health checkers from several AWS Regions. Three settings determine detection time:
- Request interval: 30 seconds (standard) or 10 seconds (fast, which costs more).
- Failure threshold: the number of consecutive failed probes before the endpoint is marked unhealthy. The default is 3.
- Endpoint and path: what is probed, such as HTTPS on port 443 with the path
/health.
This command creates a fast health check for the primary endpoint:
aws route53 create-health-check \
--caller-reference "primary-alb-$(date +%s)" \
--health-check-config '{
"Type": "HTTPS",
"FullyQualifiedDomainName": "primary-alb.us-east-1.elb.amazonaws.com",
"Port": 443,
"ResourcePath": "/health",
"RequestInterval": 10,
"FailureThreshold": 3
}'The command returns a health check ID. Put it in the primary record in the next step.
The record pair
This change batch creates both records. Replace REPLACE_WITH_HEALTH_CHECK_ID with the ID from the previous command.
{
"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" }
]
}
}
]
}Save it as failover.json and apply it:
aws route53 change-resource-record-sets \
--hosted-zone-id Z0123456789EXAMPLE \
--change-batch file://failover.jsonA CNAME cannot sit at the zone apex (example.com). For an apex name, use alias A or AAAA records that point at the load balancers. Alias records can also use "Evaluate Target Health", which treats the load balancer's own target health as the record's health.
Estimating failover time
The worst-case delay before a client reaches the DR Region is the sum of three parts:
- Detection: interval multiplied by threshold. With 10 seconds and 3 failures, that is about 30 seconds. With 30 seconds and 3 failures, it is about 90 seconds.
- Propagation: Route 53 must collect the health checker results and begin answering with the secondary record. This takes a few seconds.
- Caching: clients keep the old answer for up to the TTL, which is 60 seconds in the example. Some resolvers and applications hold answers longer than the TTL.
For a fast check with a 60-second TTL, plan for roughly two minutes, not zero. If your RTO is shorter than that, DNS alone may not meet it.
Use the data plane, not the control plane
Route 53 splits into a control plane (the API that creates and edits records) and a data plane (answering queries and running health checks). During a large event, API calls can fail or slow down while DNS answers and health checks keep working. A DR design that depends on someone editing a record mid-incident carries that risk. Configure failover records and health checks ahead of time, so the data plane does the switching. If you want a human-controlled switch, Route 53 Application Recovery Controller routing controls provide one that uses a highly available data plane, not the standard record-editing API.
Global Accelerator
Global Accelerator has three parts:
- An accelerator with two static anycast IP addresses.
- A listener for ports and protocols, such as TCP 443.
- One endpoint group per Region, each holding endpoints such as an ALB.
Each endpoint group has a traffic dial from 0 to 100. This is the percentage of traffic that group is eligible to receive, out of what would go to it based on proximity. Health checks on the endpoints run alongside the dial. An unhealthy endpoint gets no traffic, and traffic moves to healthy endpoints in other groups. Endpoint health check defaults are a 30-second interval and a threshold of 3, and a 10-second interval is available.
Use the dial to model your strategy:
- Pilot light or warm standby: primary group at 100, DR group at 0. On failover, raise the DR dial after the DR fleet is ready.
- Active/active: both groups at 100. Users go to the closest healthy Region.
Changing the dial from the CLI looks like this. Global Accelerator's API endpoint is in US West (Oregon), so pass that Region:
aws globalaccelerator update-endpoint-group \
--region us-west-2 \
--endpoint-group-arn arn:aws:globalaccelerator::111122223333:accelerator/EXAMPLE/listener/EXAMPLE/endpoint-group/EXAMPLE \
--traffic-dial-percentage 100Global Accelerator avoids DNS caching, which also makes it useful for clients that hard-code IPs or allow-list addresses in firewalls. The cost is a fixed hourly fee plus a data transfer premium, and it supports only the endpoint types listed in the table.
How the pieces fit together
Matching traffic tools to strategies
- Backup and restore: nothing is running, so a health check would just fail. Restore, then update DNS (or the dial) by hand as a runbook step.
- Pilot light and warm standby: failover records or a dial of 0 on the DR group. The DR fleet must scale before or as traffic arrives.
- Active/active: Route 53 latency or weighted routing with health checks, or Global Accelerator with both dials at 100. Failover is then mostly automatic and shows up as a load shift.
Common errors
- Shallow health checks. A check that returns 200 whenever the web server is up will not notice a broken database. A health endpoint should check critical dependencies. Do not make it so strict that a minor, non-critical failure triggers a Region failover.
- Failing over to a Region that is not ready. If DNS or the dial moves traffic before the database is promoted or the Auto Scaling group has scaled (see the earlier
failover-global-clusterandupdate-auto-scaling-groupsteps), users get errors. Sequence the steps in the runbook, or make the DR health endpoint report healthy only when the stack is ready. - Blocked health checkers. Security groups and firewalls must allow the Route 53 health checker IP ranges, or every probe fails and you fail over for no reason. For private endpoints, use a CloudWatch alarm-based health check.
- Long TTLs. A TTL of 3600 can leave clients on the failed Region for an hour. Use 60 seconds or less on DR-controlled names.
- No test of the failback path. Moving traffic back needs the same care as moving it away. The failover and failback chapter covers this.
Exercise
A team sets a fast Route 53 health check (10-second interval, threshold 3) and a TTL of 300 on their failover records. What is the approximate worst-case time before most clients reach the DR Region, and what single change would reduce it most?
Show answer
Detection takes about 30 seconds (10 x 3), plus a few seconds of propagation, plus up to 300 seconds of caching, so roughly 5.5 to 6 minutes. Lowering the TTL to 60 seconds removes most of the delay, cutting the worst case to about 2 minutes. Global Accelerator would remove the DNS caching delay entirely.
Exercise
You use Global Accelerator for a warm standby workload with two endpoint groups. What traffic dial values keep the DR Region idle, and what do you change during a planned failover?
Show answer
Set the primary Region's endpoint group to 100 and the DR Region's group to 0. During a planned failover, first scale up the DR fleet and promote the database. Then raise the DR group's dial to 100 and lower the primary group's dial to 0 (or leave it at 100 and let health checks handle it, if the primary is actually down).