Sub topic 11
Using AWS Elastic Disaster Recovery
This chapter assumes you know the pilot light strategy, RTO and RPO, and basic EC2, EBS, and VPC networking. It also assumes you can read AWS CLI commands.
Where this service fits
Earlier chapters built pilot light by hand. You replicated the database, kept AMIs current, and scaled up compute during failover. AWS Elastic Disaster Recovery (AWS DRS) packages that pattern for servers. It replicates whole machines continuously and launches them in a recovery Region when you need them.
DRS suits workloads that run on servers you can't easily rebuild from code. Examples are a legacy application on EC2, a VMware VM in an on-premises data center, or a physical server. It does not replace managed-service replication. Aurora global databases, DynamoDB global tables, and S3 replication still handle those data stores.
How DRS works
DRS has three parts.
- The replication agent is software you install on each source server. It reads disk writes at the block level and sends them to AWS.
- The staging area is a subnet in your target Region. It holds low-cost EC2 replication servers and EBS volumes that receive the data.
- Recovery instances are full-size EC2 instances. DRS launches them only during a drill or a real recovery.
Between launches, you pay for the agent licensing, the replication servers, and the staging EBS volumes. You do not pay for the full-size compute fleet. That is why DRS sits between backup and restore and warm standby on the cost scale.
Block-level replication is continuous. The agent sends each write as it happens, so the lag between source and staging is typically seconds. DRS also takes point-in-time snapshots on a schedule and keeps them for a retention period, 7 days by default. If the source was corrupted ten minutes ago, you can launch from a snapshot taken before the corruption instead of the latest state.
When you launch, a short-lived conversion server adjusts the boot volume so the operating system can boot on EC2. This step is why DRS can recover from physical servers and other hypervisors, and why launch times are minutes rather than seconds.
Recovery targets you can expect
AWS documents typical results of an RPO in seconds and an RTO in minutes. Treat these as design inputs, not guarantees. Your actual numbers depend on these factors:
- Change rate. If the source writes faster than the network can send, replication lag grows and your real RPO grows with it.
- Bandwidth. Initial sync copies every used block, which can take hours or days for large disks.
- Launch time. Boot time, conversion, and your post-launch scripts all count toward RTO.
- Dependencies. A recovered application server is useless if its database or DNS isn't ready.
Measure these in drills. Do not copy the documented figures into a runbook.
Setting up replication
Prepare the target Region
Initialize the service in the target Region first. This creates the IAM roles and the default replication and launch settings templates. You can do this in the console or by calling aws drs initialize-service --region us-west-2.
Then create a staging subnet with enough free IP addresses for the replication servers. DRS creates one replication server for roughly every 15 source disks, so large fleets need a larger subnet.
Open the network paths
The source servers need outbound access on two ports.
| Port | Destination | Purpose |
|---|---|---|
| TCP 443 | DRS and S3 endpoints in the target Region | Agent control traffic and installer download |
| TCP 1500 | Replication servers in the staging subnet | Replicated block data |
If the source is on premises, send port 1500 over Direct Connect or a VPN where you can. This keeps replication traffic off the public internet and gives it predictable bandwidth. If the source is an EC2 instance in another Region, VPC peering or a Transit Gateway works the same way.
Install the agent
On a Linux source server, download and run the installer for your target Region.
wget -O ./aws-replication-installer-init \
https://aws-elastic-disaster-recovery-us-west-2.s3.us-west-2.amazonaws.com/latest/linux/aws-replication-installer-init
sudo chmod +x ./aws-replication-installer-init
sudo ./aws-replication-installer-init --region us-west-2The installer asks for credentials and for which disks to replicate. You can also pass --aws-access-key-id and --aws-secret-access-key for unattended installs. Use a dedicated IAM user or role limited to the AWSElasticDisasterRecoveryAgentInstallationPolicy, and do not reuse administrator keys.
After installation, the server appears in the DRS console. It moves through initial sync, then reaches a healthy "Continuous data protection" state. Check progress from the CLI.
aws drs describe-source-servers --region us-west-2 \
--query 'items[].{id:sourceServerID,state:dataReplicationInfo.dataReplicationState,lag:dataReplicationInfo.lagDuration}' \
--output tableA server is ready for a recovery only after it reaches a continuous state. Launching earlier gives you an incomplete disk.
Launch settings
For each source server, DRS keeps launch settings that decide what the recovery instance looks like. These include the instance type, subnet, security groups, and IAM instance profile. They are based on an EC2 launch template that DRS manages. Three settings deserve attention.
- Right-sizing. DRS can pick an instance type that matches the source's CPU and RAM. This may overprovision or underprovision compared with your actual load. Set the type explicitly for production-critical servers.
- Subnet and security groups. The recovery VPC is a separate network. Build it with infrastructure as code before a disaster, so addresses, routes, and rules are already in place.
- Post-launch actions. DRS can run Systems Manager documents after launch. Use them to update configuration files, register the instance with a load balancer, or start application services in the right order.
Set the launch settings for every server in advance. Filling them in during an incident adds minutes and invites mistakes.
Drills and real recoveries
A drill and a recovery use the same launch process. The difference is intent. A drill launches instances to test your plan while the source keeps running. A recovery launches instances because the source is gone.
# Launch a drill from the latest state of one source server
aws drs start-recovery --region us-west-2 \
--is-drill \
--source-servers sourceServerID=s-1234567890abcdef0
# Follow the launch job
aws drs describe-jobs --region us-west-2 \
--query 'items[].{id:jobID,type:type,status:status}' \
--output tableRemove --is-drill for a real recovery. To launch from an earlier snapshot, add recoverySnapshotID= to the source-servers argument. List snapshots first with aws drs describe-recovery-snapshots.
After a drill, validate the application, not just the instance. Check that it boots, that services respond, and that data is current. Record how long each step took. Then terminate the drill instances from DRS so that they stop costing money and so that DRS marks the test as finished.
Failover and failback
Failover with DRS is a launch followed by a traffic switch. Start the recovery job, wait for the instances to pass health checks, and then move traffic. The Route 53 failover records from the traffic chapter can point at a load balancer in front of the recovery instances. Lower DNS TTLs, such as the 60 seconds in our earlier example, shorten the final step.
Failback is the return trip. Once the original site is back, you must copy the data written during the outage back to it. DRS supports this in two ways.
- For on-premises or non-AWS sources, boot the failback client on the original or replacement server. It pulls the changed blocks from the recovery instance back to the source.
- For EC2 sources, you can reverse the replication direction, so that the recovery instance becomes the replication source and the original Region becomes the target.
Either way, plan a short write freeze at the end. Stop the application on the recovery instance, let the final blocks sync, then switch traffic back. Without the freeze, writes made during the cutover are lost.
Limits and gotchas
- Only whole servers. DRS does not replicate RDS, Aurora, DynamoDB, or S3. Pair it with the replication mechanisms from the data chapter.
- Staging costs never stop. Replication servers and EBS volumes run around the clock. Exclude disks you don't need, such as temporary or swap volumes.
- Application consistency. Block replication is crash-consistent. A database on a replicated server recovers as if the power had failed. Most databases handle this, but test it.
- Service quotas. A large recovery launches many instances at once. Check EC2 vCPU quotas in the target Region before the disaster.
- Agent health. An agent that stops reporting makes the server's lag grow without notice. Alarm on the lag duration metrics.
Exercise
A team replicates a 2 TB application server with DRS. In a drill, the recovery instance boots in 12 minutes, but the data is 45 minutes old. The target is an RPO of 1 minute. Name two likely causes and one action for each.
Show answer
Likely cause one is that the source's write rate exceeds the available bandwidth, so replication lag builds up. Action: increase bandwidth, for example with Direct Connect, or reduce the replicated data by excluding temporary disks. Likely cause two is that the drill used an old point-in-time snapshot, or that the server had not reached continuous data protection. Action: launch from the latest state, and confirm the replication state and lag duration with describe-source-servers before starting the drill. Alarm on lag so the problem shows up before a disaster.