Sub topic 11
Setting Recovery Time and Recovery Point Objectives
This chapter assumes you know the difference between synchronous and asynchronous replication, and that you understand the failover sequence of detect, decide, switch, and verify. Here you will turn those mechanics into two numbers a business can agree on.
Two objectives, two questions
A recovery time objective (RTO) is the longest outage a service may have before the business is hurt. It answers: "How long can we be down?"
A recovery point objective (RPO) is the most data, measured in time, that you can afford to lose. It answers: "How far back in time may we restore?"
The two are independent. A service can recover in 30 seconds and still lose five minutes of writes. It can also lose no data and still take an hour to come back.
RPO looks backward from the failure to the last safe copy. RTO looks forward from the failure to the restored service.
What each objective depends on
RPO is set by how state is copied.
- Synchronous replication confirms a write only after a replica has it, so RPO can be zero.
- Asynchronous replication confirms first and copies later, so RPO equals the replication lag at the moment of failure.
- Nightly backups give an RPO of up to 24 hours.
RTO is set by the failover sequence. Add up the time for each step:
- Detection: the health check interval multiplied by the failure threshold.
- Decision: waiting for automation or for a person to approve.
- Switch: promoting a replica, moving an IP address, or waiting for DNS caches to expire.
- Verification: confirming the new primary serves correct data.
Worked example: estimating RTO
Suppose health checks run every 5 seconds and a node is declared dead after 3 misses. Promotion takes 20 seconds, and DNS records have a 60-second time to live (TTL).
def estimate_rto(interval, misses, decision, switch, dns_ttl, verify):
detection = interval * misses
return detection + decision + switch + dns_ttl + verify
worst_case = estimate_rto(
interval=5, misses=3, decision=0, switch=20, dns_ttl=60, verify=10
)
print(worst_case) # 105 secondsThe worst case is 105 seconds. If the target RTO is 60 seconds, this design fails the target. The largest single term is the DNS TTL, so a load balancer in front of the service, or a shorter TTL, is the better fix. Shrinking the health check interval would help less, and it would raise the risk of false positives.
Choosing the numbers
Start from the cost of downtime and data loss, then pick the cheapest design that meets them. Tighter objectives cost more.
| Target | Typical design | Relative cost |
|---|---|---|
| RPO 0, RTO seconds | Active-active with synchronous replication | High |
| RPO seconds, RTO minutes | Active-passive with asynchronous replication | Medium |
| RPO hours, RTO hours | Periodic backups restored on demand | Low |
Set objectives per service, not for the whole company. A payment ledger and a product image cache need very different numbers.
Common errors
- Quoting best-case numbers. Use the worst case for each step, including full replication lag at peak traffic.
- Forgetting dependencies. A database with a 30-second RTO does not help if the service that configures it takes 10 minutes to restart.
- Treating RPO as zero because replicas exist. With asynchronous replication, the replica is behind by the lag.
- Never testing. Untested numbers are guesses.
Exercise
A service uses asynchronous replication with a typical lag of 2 seconds that rises to 15 seconds at peak. Health checks run every 10 seconds with a threshold of 3 misses, promotion takes 30 seconds, and a load balancer handles traffic switching instantly. What RPO and worst-case RTO should you state, ignoring decision and verification time?
Show answer
The RPO to state is 15 seconds, the peak lag, because you must plan for the worst case rather than the typical 2 seconds. Detection takes 10 x 3 = 30 seconds, and promotion takes 30 seconds, so the worst-case RTO is about 60 seconds.