High availability and multi-region
High availability (HA) means a system keeps working when parts of it fail. In the cloud, failures come at three scales: a single server, an availability zone (one or more data centers in a region), or a whole region. Each step up in protection costs more and adds complexity, so the architecture starts with a question: how much downtime and data loss can the business actually accept?
Two numbers answer that question:
- RTO (recovery time objective): how long the service may be down.
- RPO (recovery point objective): how much recent data may be lost.
Diagram
Section titled “Diagram”- Global routing sends users to a healthy region, based on health checks.
- Normally all traffic goes to Region A, which itself spans three availability zones.
- Data replicates continuously to Region B. If Region A fails, the replica is promoted and routing switches over.
The options
Section titled “The options”| Design | Survives | Typical RTO | Typical RPO | Cost and complexity |
|---|---|---|---|---|
| Single zone | A server failure, if you have spares | Minutes to hours | Since the last backup | Lowest |
| Multi-zone in one region | A data center failure | Seconds to minutes | Near zero (synchronous replication within the region) | Modest: the right default for production |
| Backup and restore to another region | A region failure, slowly | Hours | Since the last backup copied | Low running cost |
| Pilot light / warm standby | A region failure | Minutes to an hour | Seconds to minutes (asynchronous replication) | Moderate |
| Active-active multi-region | A region failure with little or no interruption | Near zero | Near zero to seconds, depending on data design | Highest: data consistency is the hard part |
The numbers are typical, not guarantees. Your RTO and RPO are targets agreed with the business; a rehearsal measures the recovery time and data loss you actually achieve, and shows whether you can meet them.
How it works
Section titled “How it works”- Multi-zone first. Spreading every tier across at least two, ideally three, zones handles the most common large failures at modest cost. Managed databases and load balancers do most of the work.
- Stateless compute. App servers that hold no local state can be replaced or moved anywhere. State lives in databases, caches and object storage designed for replication.
- Data decides everything. Copying compute to another region is easy. Copying data is where latency, consistency and cost trade off. Synchronous replication across regions adds latency to every write; asynchronous replication means some recent writes may be lost in a failover.
- Health checks and automated failover, but with a human decision for full region failover in many organizations, to avoid flapping on a false alarm.
- Static stability. The standby should work without needing to call the failed region, or the control plane, during recovery.
- Rehearse. Run game days. Fail a zone or a region on purpose, measure the recovery time and data loss you actually achieve, and compare them with the RTO and RPO targets.
- Business continuity through failures that do happen, at every scale.
- Planned maintenance without downtime.
- Active-active can also put users closer to their nearest region.
- Cost: standby capacity, cross-region data transfer and duplicated services.
- Complexity: failover logic, data conflicts and testing are hard to get right.
- False confidence: an untested failover plan often fails when it’s needed.
When to use it
Section titled “When to use it”- Multi-zone: for every production workload.
- Multi-region: for systems where a region outage costs more than the extra design, running and testing effort, such as payments, emergency services and core customer platforms. Also where regulation requires a geographically separate recovery site.
When to avoid it
Section titled “When to avoid it”Don’t go active-active by default. Many systems are better served by a solid multi-zone design plus a tested backup-and-restore or warm-standby plan. Agree the RTO and RPO with the business first.
Common pitfalls
Section titled “Common pitfalls”- Replicating compute but not data, or forgetting secrets, DNS and configuration.
- Dependencies on a single region hidden in a shared service, an identity provider or a third party.
- Never testing failover, or testing it only in a smaller environment.
- Writes accepted in both regions without a strategy for conflicts.
Related patterns
Section titled “Related patterns”- Well-architected frameworks
- Landing zones
- Observability
- Scenario: disaster recovery
- Scenario: peak traffic
Glossary: CAP theorem, eventual consistency
Further reading
Section titled “Further reading”Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.