Sub topic 1
What high availability means: SLAs, RTO, and RPO
Prerequisites
This chapter assumes you know the following:
- Basic AWS concepts: Regions, VPCs, EC2, and IAM.
- TCP/IP networking and subnets.
- Basic use of the AWS CLI or the console.
- How to read YAML or JSON infrastructure templates.
You do not need to know anything about Availability Zones in detail yet. The next chapter covers them.
Why define availability before designing for it
"Highly available" has no fixed meaning. A team that tolerates a few minutes of downtime a month and a team that tolerates none will build very different systems. The first step in any multi-AZ design is to turn "it should stay up" into numbers that you can test, price, and agree on with the business.
This chapter defines four terms: availability, SLA, RTO, and RPO. It then shows how they drive design choices and where teams commonly go wrong.
Availability as a percentage
Availability is the fraction of time a system does its job correctly. You usually express it as a percentage over a period:
availability = (total time - downtime) / total timeSmall differences in the percentage mean large differences in allowed downtime. The table below uses a 30-day month (43,200 minutes) and a 365-day year.
| Availability | Downtime per month | Downtime per year |
|---|---|---|
| 99% | about 7.2 hours | about 3.65 days |
| 99.9% | about 43 minutes | about 8.8 hours |
| 99.95% | about 22 minutes | about 4.4 hours |
| 99.99% | about 4.3 minutes | about 52 minutes |
| 99.999% | about 26 seconds | about 5.3 minutes |
Two points follow from this table.
- Each extra "nine" cuts the allowed downtime by a factor of ten. It usually costs far more than ten times as much effort, because you must remove more kinds of failure.
- At 99.99%, a single manual recovery step can use up the whole monthly budget. An engineer must be paged, log in, diagnose, and act. That takes longer than 4.3 minutes. High availability above roughly 99.9% therefore requires automated recovery.
Availability of composed systems
A workload depends on several components. How you combine them changes the math.
- Serial dependencies. If a request needs component A and component B, availability is the product: 99.9% × 99.9% = 99.8%. Every hard dependency lowers the total.
- Redundant (parallel) components. If either of two independent copies can serve the request, the system fails only when both fail. Two copies at 99% give 1 − (0.01 × 0.01) = 99.99%.
def serial(*availabilities):
result = 1.0
for a in availabilities:
result *= a
return result
def parallel(*availabilities):
all_down = 1.0
for a in availabilities:
all_down *= (1.0 - a)
return 1.0 - all_down
# Two web servers (99% each) behind a load balancer (99.99%),
# in front of one database (99.9%).
web_tier = parallel(0.99, 0.99)
total = serial(0.9999, web_tier, 0.999)
print(f"web tier: {web_tier:.4%}")
print(f"overall: {total:.4%}")Running this prints a web tier of 99.9900% and an overall figure of about 99.7901%. The redundant web tier is not the weak point. The single database is, and the serial chain is only as good as its weakest link. This is the reason the next chapters spend so much time on single points of failure.
The parallel formula has a catch. It assumes the copies fail independently. Two servers in the same Availability Zone share power, networking, and a deployment pipeline, so they can fail together. Placing copies in separate failure domains is what makes the independence assumption approximately true.
SLA, SLO, and SLI
Three similar terms get mixed up often.
- SLI (service level indicator) is a measurement, such as the percentage of requests that return a non-5xx response within 300 ms.
- SLO (service level objective) is your internal target for an SLI, such as 99.95% over 30 days.
- SLA (service level agreement) is a contract. It states what a provider promises and what remedy the customer gets if the provider misses the promise, usually service credits.
AWS publishes an SLA for most services. Each one defines its own availability measure, the period it is measured over, and the credit tiers. For example, the Amazon EC2 SLA ties its Region-level commitment to running instances in more than one Availability Zone. Read the SLA for each service you use, because the definitions differ.
An SLA is not a guarantee that your workload will be up. It does two things for you:
- It tells you what the provider commits to for that component, which is an input for the composition math above.
- It gives a financial remedy, which is usually small compared with the cost of your own outage.
The availability of your workload is determined by your architecture. A service SLA only covers the service. If you deploy to one AZ, you are exposed to the failure of that AZ regardless of what the SLA says about the Region.
Set your own SLO tighter than the SLA you promise to your customers. The gap is your safety margin.
RTO and RPO
Availability percentages describe how often you fail. RTO and RPO describe what happens when you do.
- RTO (recovery time objective) is the longest acceptable time between the start of an outage and the restoration of service.
- RPO (recovery point objective) is the longest acceptable span of data loss, measured backward from the moment of failure. An RPO of 5 minutes means you can lose up to the last 5 minutes of writes.
The timeline below shows both measures for a single incident.
In this example the actual recovery point was 5 minutes and the actual recovery time was 7 minutes. Whether that is acceptable depends on the objectives you set.
RTO and RPO are independent
A workload can have a short RTO and a long RPO. A stateless web tier restarts in minutes but a nightly backup has an RPO of up to 24 hours. It can also be the reverse: synchronous replication gives an RPO of zero, but a manual rebuild process leaves a long RTO. Set each objective separately for each workload, and often for each tier.
What drives each objective
| Objective | Mostly determined by | Typical AWS mechanism |
|---|---|---|
| RPO | How data is copied | Synchronous replication across AZs (RDS Multi-AZ), backups, point-in-time recovery |
| RTO | Detection speed and how automated the recovery is | Health checks, load balancer routing, Auto Scaling replacement, automatic database failover |
An RPO of zero needs synchronous writes to a second location before the write is acknowledged. That adds a small latency to every write. Within one Region, synchronous replication across AZs is practical because the AZs are connected by low-latency links. Across Regions, the distance makes synchronous replication costly, so cross-Region designs usually accept a non-zero RPO.
Recovery strategies and their usual objectives
Disaster recovery strategies sit on a scale. Cheaper strategies have longer RTO and RPO.
| Strategy | What is running | Typical RTO / RPO |
|---|---|---|
| Backup and restore | Nothing in the recovery location | Hours |
| Pilot light | Data replicated, compute off | Tens of minutes |
| Warm standby | Scaled-down full copy | Minutes |
| Active-active | Full capacity in several locations | Seconds to minutes, RPO near zero |
A multi-AZ design within one Region is active-active across zones. It protects against the loss of one zone, but it does not by itself protect against loss of the whole Region, a bad deployment, or data corruption. The last chapter of this tutorial covers when to go further.
Turning requirements into design decisions
Work through the requirements in this order.
- Define what counts as "working." Pick one or two SLIs that reflect what users experience, such as successful checkouts rather than CPU usage.
- Set an SLO per workload. Not every system needs the same target. An internal reporting tool and a payment API can have different goals.
- Set RTO and RPO per workload and per data store. Ask the business what an hour of downtime or a minute of lost orders actually costs.
- List hard dependencies and multiply. Include DNS, identity, the database, third-party APIs, and the deployment pipeline.
- Choose the cheapest design that meets the numbers. If the numbers are not met, change the design or negotiate the numbers.
As a rule of thumb for this tutorial, a workload that needs roughly 99.9% to 99.99% availability with an RTO of minutes and an RPO of seconds to zero is a good fit for a multi-AZ design in one Region.
Common mistakes
- Counting the SLA as your availability. The SLA covers a service, not your architecture.
- Ignoring planned downtime. Deployments, patching, and schema changes count against your budget unless your SLO excludes them explicitly.
- Assuming independent failures. Shared configuration, a shared deployment, or a shared dependency makes redundant copies fail together.
- Setting an RTO that depends on a person. If recovery needs someone to run a command, your realistic RTO includes the time to page, wake up, and diagnose.
- Never measuring actual recovery. An untested RTO is a guess. A later chapter covers controlled failover tests.
Exercise
A checkout service has a load balancer (99.99%), two redundant application servers in separate failure domains (99.9% each, independent), and one database (99.95%). Compute the approximate overall availability. Then say which component to improve first.
Show answer
The application tier in parallel is 1 − (0.001 × 0.001) = 99.9999%. The serial product is 0.9999 × 0.999999 × 0.9995, which is about 99.94%. The database at 99.95% is the weakest link and the single point of failure, so make it redundant first, for example with a Multi-AZ configuration. Improving the already redundant application tier would change almost nothing.
Exercise
Your business states: "We can lose at most 30 seconds of orders and must be serving again within 5 minutes." State the RPO and RTO. Say whether a design that relies on a nightly backup and an on-call engineer meets them.
Show answer
The RPO is 30 seconds and the RTO is 5 minutes. A nightly backup gives an RPO of up to 24 hours, and a human-driven restore adds paging and diagnosis time on top of restore time. Neither objective is met. You need continuous or synchronous replication and automated failover.