Sub topic 2
Setting goals: availability, latency, RTO and RPO
This chapter assumes you know basic cloud networking and DNS, can run stateless web services behind a load balancer, and have used a relational or NoSQL database. You should also be comfortable treating availability and latency as service goals. Before you pick a design, you need numbers that justify it. Active-active costs a lot, so the goals must demand it.
Availability targets
Availability is the share of time a service answers requests correctly. It is usually quoted in "nines".
| Target | Allowed downtime per year |
|---|---|
| 99.9% | about 8.8 hours |
| 99.95% | about 4.4 hours |
| 99.99% | about 52 minutes |
| 99.999% | about 5 minutes |
A single region can often reach 99.9% to 99.99% with multiple availability zones. Going beyond that usually means surviving a whole-region failure, which is the main reason to run in several regions.
Your real availability is also limited by dependencies. If your service needs a database at 99.99% and a payment provider at 99.9%, the combined ceiling is roughly 99.89%. Adding regions does not help if every region depends on one shared component.
Latency targets
Latency is the time a request takes from the user's device to a response. Distance sets a floor. Light in fibre travels about 200 km per millisecond, so a round trip from Frankfurt to Virginia costs roughly 80 to 100 ms before any processing.
If your goal is "p95 under 150 ms for users on three continents", a single region cannot meet it for everyone. Serving each user from a nearby region can. Use percentiles such as p95 and p99 rather than averages, because slow requests drive user experience.
Note that read latency and write latency differ. Reads can come from a local replica. Writes that must be confirmed by another region pay the cross-region round trip. Later chapters cover this trade-off.
RTO and RPO
Two recovery targets describe how you handle failure:
- RTO (recovery time objective) is the longest outage you accept before service is restored.
- RPO (recovery point objective) is the most data you accept losing, measured as time. An RPO of 30 seconds means you can lose up to 30 seconds of writes.
RPO is measured backward from the failure to the last replicated write. RTO is measured forward from the failure to restored service.
Active-passive designs typically have an RTO of minutes, because the standby must be promoted. Active-active aims for an RTO near zero, since other regions are already serving traffic. RPO depends on replication. Asynchronous replication gives a small but nonzero RPO. Synchronous replication gives an RPO of zero but adds latency to every write.
Turning goals into a decision
Write down goals per service, not per company. A checkout API and an analytics dashboard need different targets.
- State the availability target and the cost of downtime per hour.
- State the p95 latency target for each user population.
- State the RTO and RPO for each data type.
- Check whether a well-built single region with multiple zones already meets them.
Exercise
A service must stay available if a region fails, tolerate losing at most 5 seconds of writes, and recover within 1 minute. Which numbers are the RTO and RPO, and does asynchronous replication with a 2-second typical lag fit?
Show answer
The RTO is 1 minute and the RPO is 5 seconds. Asynchronous replication with 2 seconds of typical lag can fit, but only if lag stays below 5 seconds during load and failures, so you must monitor lag and alert before it approaches the RPO.