Sub topic 12
Running failover and failback
This chapter assumes you know the four DR strategies, RTO and RPO, Route 53 failover records, and Aurora global databases. It covers how to run a Regional failover and how to return to the primary Region afterward.
Failover is a runbook, not an event
Failover is the act of moving production to the DR Region. Failback is the move back to the primary Region once it is healthy. Both should be written down as ordered steps, so the on-call engineer does not improvise during an outage.
A typical failover runbook for pilot light or warm standby has these steps:
- Declare the disaster. Decide who has the authority, and decide it before the incident.
- Stop writes to the primary if it is still partly reachable, to limit data divergence.
- Promote the data tier in the DR Region.
- Scale the compute tier to production capacity.
- Redirect traffic.
- Verify with a smoke test, then announce completion.
The order matters. Redirect traffic last, so users do not reach a DR stack whose database is still read-only or whose fleet is undersized.
Failover commands
Two steps from the earlier chapters do most of the work. The first scales the dormant DR Auto Scaling group. The second moves the Aurora global database's primary role.
# Scale the dormant DR Auto Scaling group up from its minimal size
aws autoscaling update-auto-scaling-group \
--region us-west-2 \
--auto-scaling-group-name app-dr \
--min-size 4 \
--desired-capacity 4 \
--max-size 12
# Planned switchover of an Aurora global database to the DR Region's cluster
aws rds failover-global-cluster \
--region us-west-2 \
--global-cluster-identifier app-global \
--target-db-cluster-identifier arn:aws:rds:us-west-2:111122223333:cluster:app-dr-clusterThe failover-global-cluster command performs a managed, planned switchover. It waits for replicas to catch up, so it loses no data. During a real Regional outage the primary may be unreachable, so you may need to detach the secondary cluster and promote it instead. That path can lose the writes that had not yet replicated, and your actual RPO is the replication lag at that moment.
Traffic redirection
With the Route 53 failover records from the previous chapters, traffic moves on its own when the primary health check fails. The switch is not instant, because resolvers cache answers for the record's TTL. A 60-second TTL plus the health check detection time sets a floor on your RTO.
Some teams prefer a manual switch. They use a health check that an operator controls (for example, a CloudWatch alarm or a calculated health check) so that DNS fails over only when a person decides. This avoids an automatic failover caused by a false alarm.
Failback
Failback is often riskier than failover, because it happens when nobody is under pressure and teams skip rehearsal. The main problem is that the DR Region now holds the newest data.
- Confirm the primary Region is stable, not just reachable.
- Rebuild the primary's data tier from the DR Region. For Aurora, add the old Region back as a secondary cluster, let it resync, then run a planned switchover. For backup and restore, copy backups back or restore from the DR copy.
- Bring the primary compute up with infrastructure as code, and test it before it receives traffic.
- Schedule the cutover in a low-traffic window and redirect traffic.
- Scale the DR Region back down to its resting size.
Never fail back by pointing traffic at a primary whose data is stale. Writes made in the DR Region would disappear.
Common errors
- The runbook lives only in the primary Region, so it is unreachable during the outage. Store it in the DR Region or outside AWS.
- DR scripts hard-code the old Region's resource IDs.
- Nobody lowered the TTL beforehand, so clients keep using the dead endpoint.
- Failback was never rehearsed, and data diverges.
Exercise
Your Aurora global database primary Region fails and the primary is unreachable. Name one reason your actual RPO may be greater than zero, and state where in the runbook traffic should be redirected.
Show answer
An unplanned promotion of the secondary cluster can lose writes that had not replicated before the failure, so the RPO equals the replication lag at that moment. Traffic should be redirected last, after the database is promoted and the compute fleet is scaled to production size.