Skip to content
SparkTime, home
System Design From Zero to Interview-Ready
Lessons
1 · System Design Foundations
2 · APIs and Communication
3 · Capacity Estimation
4 · Core Building Blocks
5 · Databases
6 · Distributed Systems
7 · Reliability and Operations
8 · Architecture and Security
9 · Interview Method and Foundation Case Studies
10 · Real-World Case Studies
11 · Large-Scale Case Studies
12 · Interview Readiness
Lesson 24 of 45

Lesson 24 · Reliability and Operations

High Availability and Disaster Recovery: Redundancy, Failover, RPO, RTO and Multi-Region

How systems survive failures of servers, availability zones and whole regions, and recover from data disasters. Covers failure domains, redundancy and failover, availability arithmetic with correlated failures, RPO and RTO, the four disaster-recovery strategies from backup-and-restore to active-active, multi-region write strategies, backups that actually restore, and safe deployments.

On this page

Key takeaways

  • High availability handles common failures (a server, a zone) automatically; disaster recovery restores service and data after rare, large events (a region, corruption, human error) within stated objectives.
  • Design across failure domains: redundancy only helps when the copies do not share a cause of failure.
  • RPO (how much data you may lose) and RTO (how long you may be down) decide the disaster-recovery strategy, from backup-and-restore to multi-site active-active, with cost rising at each step.
  • Replication protects against loss of hardware, not against bad writes; you still need tested, isolated, point-in-time backups.
  • Most outages start with changes, so safe deployments and configuration changes are part of availability.

Pixly's team proudly reports "we have backups". Then a storage misconfiguration corrupts the primary database on a Saturday night. The backups exist, in the same account and region. Restoring 2 TB from them takes nine hours, the restore script has never been run end to end, and nobody is sure which backup predates the corruption. The site is down for most of Sunday, and some data from the last six hours is gone for good.

High availability and disaster recovery are about making those numbers (how long down, how much lost) deliberate decisions made in advance, rather than discoveries made during the worst night of the year. This article covers how to design redundancy that actually works, how to choose a disaster-recovery strategy from your objectives, and the operational habits that make recovery real.

What you will learn

#
  • The difference between high availability and disaster recovery.
  • Failure domains, and why redundancy must cross them.
  • Redundancy and failover patterns, and availability arithmetic with correlated failures.
  • Error budgets: how much unavailability to plan for.
  • RPO and RTO, and the four disaster-recovery strategies.
  • Multi-region designs and how writes are handled.
  • Backups that restore, and why replication is not a backup.
  • Deployments and configuration changes as availability risks.

High availability versus disaster recovery

#

High availability (HA)

Disaster recovery (DR)

Handles

Common failures: a process, a server, a disk, an availability zone

Rare, large events: a region outage, data corruption, deletion, ransomware, a bad mass change

Response

Automatic, in seconds to minutes

Planned procedure, often partly manual, in minutes to hours

Mechanism

Redundant components, health checks, failover

Backups, replicas in another region, runbooks, rehearsals

Measure

Availability (nines)

RPO and RTO

You need both. A multi-zone active system has excellent HA and can still lose data permanently to one bad DELETE statement, because the replicas copy it instantly.

Failure domains

#

A failure domain is a set of components that can fail together because they share something: power, network, hardware, software, configuration or people.

Domain

Example cause

Process

Out-of-memory crash, deadlock

Host

Hardware failure, kernel panic

Rack

Top-of-rack switch or power failure

Availability zone

Power or cooling loss in a data centre, flooding

Region

Large-scale network or control-plane problem, natural disaster

Provider or account

Billing lockout, compromised credentials, account-wide misconfiguration

Software version

A bad release deployed everywhere at once

Configuration

A wrong setting pushed globally

Data

Corruption, accidental deletion, a buggy migration

Redundancy protects only against failures in domains the copies do not share. Two servers in the same rack do not survive a rack failure; two regions running the same buggy release do not survive the bug. Good design asks, for each critical component: which domain failures does this redundancy cover, and which does it not?

Cloud providers expose availability zones, separate data centres in one region with independent power and networking, so that applications can spread across them. Amazon's S3 documentation, for example, describes zones as physically separated by a meaningful distance while within 100 km of each other, and S3 stores objects across at least three of them for most storage classes (Data protection in Amazon S3). Spreading across zones is the default way to achieve high availability within a region.

Redundancy and failover patterns

#
  • N+1, N+2: run one or two more instances than the load requires, so losing some does not overload the rest (article 07's capacity with a zone lost).
  • Active-active: all copies serve traffic. Failover is just "stop sending to the broken one". Requires the copies to share or synchronise state.
  • Active-passive: one copy serves, another waits. Failover means promoting the passive copy (article 15). Simpler for stateful components; failover takes time and must be tested.
  • Stateless tiers (app servers) are easy to make active-active across zones. Stateful tiers (databases) usually run a primary with a synchronous standby in another zone and automatic failover.

Static stability is worth designing for: the Amazon Builders' Library describes keeping enough pre-provisioned capacity in each zone that the loss of one zone requires no new resources to be launched, because the systems that launch resources may themselves be impaired during the event (Static stability using Availability Zones).

Availability arithmetic, honestly

#

Article 02 showed that redundancy multiplies failure probabilities if failures are independent:

Code
One zone at 99.9%: unavailable 0.1% of the timeThree zones, any one sufficient, independent: 0.001^3 = 1 in a billion unavailable

Real systems never achieve that, because of correlated failures: a shared dependency (one database primary, one DNS provider, one configuration service), a release deployed to all zones, an operator mistake. The real availability is dominated by these shared causes. When you estimate, include them:

Code
Zone-redundant app tier:         ~ very high (independent zones)x one database primary (with standby, ~minute failover): 99.95% (assumption)x one global config service:     99.95% (assumption)x deployment-caused incidents:   99.9%  (assumption)= about 99.8%

The lesson: after zone redundancy, the shared components and change processes decide your availability. That is where to invest next.

Error budgets: how much availability to buy

#

Google's SRE book argues that 100% reliability is the wrong target for almost everything: users cannot tell the difference beyond a point (their own networks and devices fail more often), and each extra nine costs far more. It proposes setting an availability target and treating the remainder as an error budget that can be spent on releasing changes faster (Embracing Risk). If the target is 99.9% a month, about 43 minutes of failure is acceptable; when the budget is used up, the team slows releases and focuses on reliability.

For design, the point is: choose the target from the business need, then design to it. A payment API and an internal reporting tool deserve different targets and different costs.

RPO and RTO

#

Two numbers define what "recovered" means:

  • Recovery Point Objective (RPO): the maximum acceptable data loss, measured in time. RPO of 5 minutes means losing at most the last 5 minutes of writes.
  • Recovery Time Objective (RTO): the maximum acceptable downtime before service is restored.
Code
        last good copy          disaster              service restored-----------|-----------------------X-------------------------|---------->           <------- RPO -------->   <---------- RTO ---------->           (data written here may be lost)   (users cannot use the system)

Both come from the business: what does an hour of downtime cost, and what does losing an hour of orders cost? Then they drive the technical strategy.

The four disaster-recovery strategies

#

AWS's disaster-recovery whitepaper describes four broad strategies, from cheapest and slowest to most expensive and fastest (Disaster recovery options in the cloud). The ideas apply to any provider or your own data centres.

Strategy

What runs in the recovery region

Typical RPO

Typical RTO

Cost

Backup and restore

Nothing; backups (and infrastructure definitions) are copied there

Hours (time since last backup)

Hours (provision everything, restore data)

Lowest

Pilot light

Data replicated continuously; core infrastructure defined but compute switched off

Minutes or less

Tens of minutes (switch on and scale up)

Low

Warm standby

A scaled-down but fully working copy, receiving replicated data

Minutes or less

Minutes (scale up and switch traffic)

Medium

Multi-site active-active

Full copies serving traffic in several regions

Near zero for regional failure

Near zero (stop routing to the failed region)

Highest

Important details from the whitepaper:

  • Infrastructure as code is essential for every strategy: without it, rebuilding in another region is slow and error-prone.
  • Pilot light versus warm standby: pilot light cannot serve requests until you switch on and scale compute; warm standby can serve immediately at reduced capacity.
  • Prefer data-plane operations for failover: control planes (the APIs that create and configure resources) are typically less available than data planes, so a recovery plan that depends on launching lots of new resources during a regional event is fragile.
  • Even active-active needs backups: for data corruption or deletion, the recovery point will be before the problem was discovered, and replication will have copied the damage to every region.
  • Test regularly, or you do not know whether the strategy works.

Multi-region designs

#

Running in several regions improves latency for distant users and survives regional outages, but it forces you to decide how writes work. The AWS whitepaper names three approaches (Disaster recovery options in the cloud):

Write strategy

How

Trade-off

Write global

All writes go to one primary region; other regions serve reads

Simple consistency; distant writers pay latency; failover promotes another region

Write local

Each region accepts writes; data replicates both ways

Low write latency everywhere; conflicts must be resolved (often last writer wins in managed products)

Write partitioned

Each record has a home region (for example by user), which takes its writes

Low latency for most users, no conflicts; a user's writes depend on their home region

From article 19: write-local is AP behaviour with conflict resolution; write-global is CP for writes; write-partitioned avoids conflicts by giving every piece of data one owner. Data residency rules (some data must stay in a country) often push designs towards write-partitioned.

Traffic steering between regions uses DNS-based routing (with the TTL caveats from article 03), anycast or global load balancers. Decide in advance whether failover is automatic (fast, but a false alarm moves traffic unnecessarily and costs some data and availability) or manually triggered with automated steps ("push one button"). The AWS whitepaper notes that many organisations prefer manually initiated, automated failover for regional events for this reason.

Backups that actually restore

#

Replication protects against losing machines. Backups protect against losing data: deletion, corruption, bugs, attackers. A sound backup strategy:

  1. Point-in-time recovery for databases: base backups plus continuously archived change logs, so you can restore to any moment, such as one minute before the bad migration. PostgreSQL documents this as continuous archiving and point-in-time recovery (PostgreSQL: Continuous Archiving and PITR).
  2. Isolation: keep copies in another region and another account or security boundary, so that compromised credentials or an account-wide mistake cannot delete both production and backups. The AWS whitepaper recommends cross-account backups for this reason.
  3. Immutability: use write-once or object-lock features so backups cannot be altered or deleted for a period, which protects against ransomware.
  4. Back up more than data: infrastructure definitions, configuration, secrets (in a secure way), and machine images.
  5. Test restores regularly, time them, and compare the time with your RTO. A backup you have never restored is a hope.
  6. Know your retention: how far back can you go? Corruption is sometimes discovered weeks later.

Change is the biggest risk

#

A large share of outages in practice follow a deployment or a configuration change. Treat change safety as part of availability:

  • Progressive rollouts: canary to a small percentage, then expand, watching error rates and latency (article 08's weighted routing).
  • Automatic rollback when health metrics degrade.
  • Feature flags to turn features off without redeploying.
  • Zone-by-zone and region-by-region deployment, so a bad release does not hit every failure domain at once.
  • Configuration changes treated like code: reviewed, versioned, rolled out gradually.

Worked example: Pixly's availability plan

#

Objectives (from the business): viewing 99.95% per month; uploads 99.9%. Regional DR: RPO 1 minute, RTO 30 minutes. Data corruption: restore to any point in the last 14 days.

Within the region (high availability):

Component

Redundancy

Load balancer

Managed, spans 3 zones

API servers

6 per zone, sized so 2 zones carry the peak (static stability)

Redis

Primary and replica in different zones, automatic failover; the database can survive a cold cache with load shedding (article 23)

PostgreSQL

Primary plus synchronous standby in another zone, automatic failover; read replicas in the third zone

Object storage

Multi-zone by design

Queues

Managed, multi-zone

Across regions (disaster recovery): warm standby.

  • Asynchronous database replica in a second region (RPO about the replication lag, normally well under a minute).
  • Object storage replicated to the second region.
  • A small API fleet running there behind its own load balancer, receiving synthetic test traffic continuously, so the team knows it works.
  • Infrastructure as code for scaling it to full size.
  • Failover: an engineer triggers an automated runbook (promote the regional replica, scale the fleet, switch traffic), rehearsed quarterly. Target 30 minutes.

Why not active-active? It would cost roughly double, and require a multi-region write strategy for users, photos, likes and follows, with conflicts to handle. Pixly's objectives (30-minute RTO for a rare regional event) do not justify that today. The design records what would change the decision: a requirement for sub-minute regional RTO, or a large user base in a distant region needing low write latency.

Backups: daily base backups and continuous log archiving, copied to a separate backup account in another region with a 14-day immutability lock; monthly restore drills that measure restore time.

Failure modes

#

Failure

Effect

Mitigation

Redundant copies share a dependency

Both fail together

Map failure domains; remove shared single points

Failover never tested

It fails during the real event

Regular drills and game days

DNS TTL too long

Clients stay on the failed region

Short TTLs on failover records; global load balancers

Backups in the same account

Lost along with production

Cross-account, cross-region, immutable copies

Restore slower than RTO

Extended outage

Measure restore times; keep warm replicas

Automatic regional failover on a false alarm

Unnecessary data loss and disruption

Human-triggered, automated runbooks for regional events

A bad change deployed everywhere

All redundancy fails at once

Progressive, zone-by-zone rollouts with automatic rollback

Trade-offs

#

Choice

You gain

You pay

Multi-zone

Survives zone failures automatically

Some cross-zone latency and data-transfer cost

Backup and restore only

Low cost

Hours of downtime and data loss for regional disasters

Warm standby

Minutes of RTO

Ongoing cost of a running secondary

Active-active

Near-zero RTO, regional latency benefits

Highest cost; multi-region write complexity

Synchronous cross-region replication

Near-zero RPO across regions

Write latency on every request

Common mistakes

#
  • Saying "multi-region" without stating RPO, RTO or a write strategy.
  • Treating replicas as backups.
  • Assuming independent failures and quoting impossible nines.
  • Never rehearsing failover or restores.
  • Depending on control-plane operations (creating resources) during a regional failover.
  • Deploying the same change everywhere at once.

In an interview

#
  • State the availability target and the RPO and RTO before choosing a strategy.
  • Default to multi-zone within a region for HA; justify multi-region with requirements.
  • Name the DR strategy (backup and restore, pilot light, warm standby, active-active) and why.
  • If multi-region, state the write strategy and how conflicts are avoided or resolved.
  • Mention tested, isolated backups with point-in-time recovery.

Exercises

#

Exercise 1

Pick the strategy

#

Choose a DR strategy and explain:

  1. An internal HR portal used during office hours. RPO 24 hours, RTO 1 business day.
  2. An e-commerce site. RPO 5 minutes, RTO 1 hour, budget-conscious.
  3. A payments API for merchants. RPO near zero, RTO under 5 minutes.

Exercise 2: Find the gaps

#

A team's DR plan: "Nightly database snapshots stored in the same region. A standby region exists in our documentation. DNS TTL for the API is 24 hours. We have never run a failover because it is risky." List every gap and a fix for each.

Exercise 3: Availability with shared parts

#

An API runs in 3 zones (any one zone can carry the load), but all zones depend on one database primary that has 99.95% availability including failovers, and one authentication service at 99.9%. Estimate the overall availability and say where to invest next.

Exercise 4: Multi-region profiles

#

Users in India and Europe edit their profiles. You run active-active in both regions with write-local replication and last-writer-wins. Describe a scenario that loses data, and propose a better write strategy.

Show solutionHide solution
  1. Backup and restore. Daily backups copied to another region (and account); infrastructure as code to rebuild. The cost of anything more is not justified by the objectives.
  2. Pilot light or warm standby. Continuous asynchronous replication of the database and object storage to a second region gives an RPO of minutes or less. Pilot light (compute off, defined in code) can meet a 1-hour RTO if scaling up is automated and rehearsed; warm standby gives more margin and confidence at a higher steady cost. Given the budget focus, pilot light with regular drills is reasonable.
  3. Multi-site active-active or hot standby, with near-synchronous data protection for payment records. Writes for each merchant could be partitioned by home region, with synchronous replication of critical records to a second region if near-zero RPO across regions is truly required (accepting the latency for those writes). Expensive, and appropriate for the stakes.

Exercise 2

Show solutionHide solution
  • Snapshots in the same region: a regional event loses them too. Copy to another region and a separate account, with immutability.
  • Nightly only: RPO is up to 24 hours. Add continuous log archiving for point-in-time recovery, or replication if a smaller RPO is needed.
  • Standby region "exists in documentation": it does not exist. Build it as code, at least as pilot light, and keep it deployable.
  • DNS TTL 24 hours: clients would keep using the failed region for up to a day. Lower the TTL on failover records (for example 60 seconds) or use a global load balancer or anycast.
  • Never run a failover: the plan is unproven. Schedule regular drills, starting in staging and then in production during low traffic, and measure RTO and RPO achieved.
  • Also missing: stated RPO and RTO objectives, restore-time measurements, and a runbook with owners.

Exercise 3

Show solutionHide solution

The zone-redundant API tier is very highly available on its own. The shared parts dominate:

Code
0.9995 (database) x 0.999 (auth) = about 0.9985, or 99.85%

That is roughly 13 hours of unavailability a year, almost all from the two shared dependencies, regardless of how many zones the API spans.

Invest next in: the authentication service (the weakest link): make it multi-zone and redundant, cache token validation so short auth outages do not block requests already signed in (for example by validating signed tokens locally, article 28). Then the database: faster failover, connection handling that survives failover, and read-only degradation for reads when the primary is failing over.

Exercise 4

Show solutionHide solution

A user in India updates their bio in the Indian region at 10:00:00.200 while their phone (or another session, for example a laptop routed to Europe) updates their avatar in the European region at 10:00:00.100 by its clock. If the whole profile row replicates and the conflict is resolved by timestamp, one region's version wins entirely: the other change is silently lost. With clock skew between regions, even the "later" change in real time can lose.

Better strategies:

  • Write partitioned by home region: each user has a home region (where they signed up or chose); all profile writes go there, and other regions get read replicas. No conflicts; a European session of an Indian user pays extra latency for profile writes, which are rare.
  • Field-level merges if active-active writes are essential: replicate individual fields with versions, so bio and avatar changes do not overwrite each other, and handle true conflicts on the same field explicitly.

Where to go next

#

Sources & further reading

  1. docs.aws.amazon.com
  2. docs.aws.amazon.com
  3. docs.cloud.google.com
  4. sre.google
  5. docs.aws.amazon.com
  6. postgresql.org
  7. aws.amazon.com
  • Guide · Technology

    Start Here: Your Roadmap from Zero to Job-Ready DSA

  • Guide · Technology

    Heaps and Priority Queues

  • Guide · Career

    A LinkedIn Profile That Gets Recruiter Messages