Platform Engineering · Lesson 159

Multi-Region Architecture: Active/Active, Active/Passive, RTO, and RPO

A single Region is a single failure domain. Running in two Regions protects against losing one, and the design choice comes down to two numbers the business sets: RTO (recovery time objective: how long you may be down) and RPO (recovery point objective: how much recent data you may lose). From cheapest to most resilient: backup and restore, pilot light, warm standby, active/passive at full scale, and active/active, where both Regions take traffic. This lesson takes one orders service through a Region failure, and shows the two failures that catch teams out: active/active writes that conflict, and a standby Region that cannot scale when it is needed.

Difficulty: Master · Know this first: Lesson 158, Lesson 72

What you will learn

By the end of this lesson you can work at four levels:

This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar adds up minutes from a Region failing to orders flowing again. It is a worked example, not a measurement. The capacity and write-conflict hops are where multi-Region designs fail on the day.

Try it: pick a pattern for the RTO and RPO

Pick the pattern, the replication, and whether quotas are raised in the second Region. The readouts show the RTO and RPO you would get, and the cost against a single Region.

18 minRTO
1 sRPO
1.3×cost

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Multi-Region design grows in four levels: reading RTO and RPO, choosing a pattern, building and rehearsing failover, and running active/active safely.

Basic — Read RTO and RPO

At the basic level you can explain what each number protects and what a pattern achieves.

  • RTO: time down; RPO: data lost, measured in time.
  • The pattern ladder: backup and restore, pilot light, warm standby, active/passive, active/active.
  • Replication lag as the real RPO.

Where it breaks: asking for "zero and zero" without asking what it costs.

Try it: Basic

Which pattern keeps data replicated but compute switched off in the second Region?

Now do it: Map three of your services to a pattern.

Intermediate — Choose a pattern

At the intermediate level you choose and cost a pattern per service.

  • RTO and RPO per service from the business owner.
  • Replication type and its measured lag; global routing and its shift time.
  • The monthly cost of each step up the ladder.

Try it: Intermediate

A service needs RTO 4 hours and RPO 1 hour. What is likely enough?

Now do it: Price two patterns for one service.

Advanced — Build and rehearse failover

At the advanced level failover is a tested procedure.

  • Quotas, images, secrets, and configuration ready in the second Region.
  • Failover criteria and who decides; a runbook with verification by synthetic transactions.
  • Quarterly drills that measure achieved RTO and RPO, including failback.

Try it: Advanced

What should a failover drill measure?

Now do it: Run a drill for one service in a test environment.

Master — Active/active safely

At the master level both Regions serve, and the data model is built for it.

  • Records homed in a Region (by customer or tenant), with routing that sends writes home.
  • Or a globally consistent database, with write latency budgeted.
  • Idempotency keys so retries in the other Region do not duplicate work.

Trade-off: active/active doubles running cost and adds data complexity; it buys near-zero RTO and capacity that is always tested.

Try it: Master

How do you stop a retry in the other Region from creating a duplicate order?

Now do it: Add an idempotency key to one write API.

Go deeper

Measuring the real RPO and checking the standby Region (read-only):

# Aurora Global Database: replication lag to the secondary Region
aws rds describe-global-clusters --query "GlobalClusters[].GlobalClusterMembers[].[DBClusterArn,IsWriter]"
aws cloudwatch get-metric-statistics --namespace AWS/RDS --metric-name AuroraGlobalDBReplicationLag \
  --dimensions Name=DBClusterIdentifier,Value=orders-eu-central-1 --statistics Maximum \
  --start-time "$(date -u -d '-1 day' +%FT%TZ)" --end-time "$(date -u +%FT%TZ)" --period 3600
# quotas in the standby Region, against what peak needs
aws service-quotas get-service-quota --region eu-central-1 --service-code ec2 --quota-code L-1216C47A
# Azure SQL: failover group state; Google Cloud SQL: replicas
az sql failover-group list -g rg-orders -s sql-orders-weu --query "[].{name:name, role:replicationRole, state:replicationState}" -o table
gcloud sql instances list --filter="masterInstanceName:orders" --format="table(name,region,state)"

The pattern ladder with typical numbers (yours depend on data size and automation):

Homing writes for active/active: route each customer to a home Region (by a customer ID hash or residency), let both Regions serve reads, send writes to the home Region, and on a Region failure move its customers' home to the survivor after the data has caught up. This keeps each record with a single writer.

One time it broke

This is a composite of a failure pattern that keeps repeating; the details are illustrative. Two Regions, one order, two writers.

Timeline

  • LaunchThe orders service runs active/active in two Regions with asynchronous multi-writer replication and last-writer-wins. Users are routed by latency.
  • Black Friday, 10:00Load and network jitter push some users' requests between Regions. Replication lag rises to 2 seconds.
  • 10:00–22:00Concurrent updates to the same orders and stock rows in both Regions overwrite each other. Client retries that cross Regions create duplicate orders.
  • Next 2 days2,300 lost updates and 410 duplicates are found by reconciling with the payment provider, and fixed by hand.

What changed after

Each customer has a home Region for writes, reads are served locally, every write API takes an idempotency key, and a conflict counter is monitored with an alert.

Try it yourself, from scratch

Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.

Before you start: Python 3 for the program. The cloud steps need the AWS CLI with read access; adapt the Region names to yours.

1. Linux commands

Type each one, read what it prints, and compare it with the note above it.

  1. Measure round-trip time between two Regions from a VM in one of them: it is the cost synchronous replication adds to every write.

    for host in ec2.eu-central-1.amazonaws.com ec2.us-east-1.amazonaws.com; do
      printf "%s " "$host"; curl -s -o /dev/null -w "%{time_connect}\n" "https://$host"
    done

    Options: %{time_connect} is the TCP handshake time, close to one round trip.

    Expect: A few milliseconds to a nearby Region, 70 ms or more across the Atlantic. Read-only: it lists or describes, and changes nothing.

  2. Check a quota in the standby Region before you need it: running on-demand standard instances (vCPUs).

    aws service-quotas get-service-quota --region eu-central-1 --service-code ec2 --quota-code L-1216C47A --query "Quota.[QuotaName,Value]" --output text

    Expect: The quota name and its current value; compare it with the vCPUs your peak needs. Read-only: it lists or describes, and changes nothing.

  3. List global database clusters and which member writes.

    aws rds describe-global-clusters --query "GlobalClusters[].GlobalClusterMembers[].[DBClusterArn,IsWriter]" --output table

    Expect: One writer and one or more secondaries, or nothing if you do not use Aurora Global Database. Read-only: it lists or describes, and changes nothing.

2. Python: multi_region.py

This program replays a Region failure for each pattern to give the RTO and RPO it achieves, including what happens when the standby Region's quotas were never raised. Then it runs a day of active/active writes with asynchronous replication, first with last-writer-wins and no idempotency, then with records homed in one Region and idempotency keys. Save it as multi_region.py, then run it.

# multi_region.py
import random

PATTERNS = {   # minutes: detect, decide, data, compute at standby quotas, routing; RPO in seconds
    "backup and restore": (5, 6, 180, 120, 3, 3600),
    "pilot light":        (5, 6, 10, 35, 3, 1),
    "warm standby":       (5, 6, 1, 9, 3, 1),
    "active/passive":     (5, 6, 1, 0, 3, 1),
}
print(f"{'pattern':<20} {'RTO min':>8} {'RPO':>7}   with default quotas in the standby Region")
for name, (detect, decide, data, compute, route, rpo_s) in PATTERNS.items():
    rto = detect + decide + data + compute + route
    capped = rto + (240 if compute else 0)
    rpo = f"{rpo_s // 60} min" if rpo_s >= 60 else f"{rpo_s} s"
    print(f"{name:<20} {rto:>8} {rpo:>7}   {capped} min" + ("" if compute else " (already at full scale)"))
print("target: RTO 30 min, RPO 1 min\n")

rnd = random.Random(3)
LAG = 1.5   # seconds of replication lag between the Regions
def day(homed, idempotent):
    store = {}             # order -> (value, region, time)
    seen = set()           # idempotency keys already applied
    lost = dup = 0
    for t in range(20000):
        order = rnd.randrange(150)              # busy day: popular orders and stock rows are hot
        region = "eu-west-1" if (homed and order % 2 == 0) else ("eu-central-1" if homed else rnd.choice(["eu-west-1", "eu-central-1"]))
        now = t * 0.5
        key = (order, t // 3)                  # a client retry reuses the same key
        if idempotent and key in seen:
            continue
        seen.add(key)
        prev = store.get(order)
        if prev and prev[1] != region and now - prev[2] < LAG:
            lost += 1                          # the other Region's write was not replicated yet: last writer wins
        if not idempotent and rnd.random() < 0.02:
            dup += 1                           # a timed-out request retried in the other Region
        store[order] = (t, region, now)
    return lost, dup

for label, homed, idem in (("active/active, last-writer-wins", False, False), ("records homed, idempotency keys", True, True)):
    lost, dup = day(homed, idem)
    print(f"{label:<34} lost updates {lost:>4}   duplicate orders {dup:>4}")

Run it, and you should see this output:

$ python3 multi_region.py
pattern               RTO min     RPO   with default quotas in the standby Region
backup and restore        314  60 min   554 min
pilot light                59     1 s   299 min
warm standby               24     1 s   264 min
active/passive             15     1 s   15 min (already at full scale)
target: RTO 30 min, RPO 1 min

active/active, last-writer-wins    lost updates  134   duplicate orders  422
records homed, idempotency keys    lost updates    0   duplicate orders    0

3. What to notice

4. Advanced: every step as one Bash script

The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/multi-region-active-active-and-active-passive && cd ~/labs/multi-region-active-active-and-active-passive) and save this as lab.sh.

#!/usr/bin/env bash
# The Linux steps of "Multi-Region Architecture: Active/Active, Active/Passive, RTO, and RPO", as one script (save it as lab.sh).
#
#   ./lab.sh          run every step, in order
#   ./lab.sh 2 4      run only steps 2 and 4
#   ./lab.sh --list   list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.

STEPS=(
  'Measure round-trip time between two Regions from a VM in one of them: it is the cost synchronous replication adds to every write.'
  'Check a quota in the standby Region before you need it: running on-demand standard instances (vCPUs).'
  'List global database clusters and which member writes.'
)

step_1() {
for host in ec2.eu-central-1.amazonaws.com ec2.us-east-1.amazonaws.com; do
  printf "%s " "$host"; curl -s -o /dev/null -w "%{time_connect}\n" "https://$host"
done
}

step_2() {
aws service-quotas get-service-quota --region eu-central-1 --service-code ec2 --quota-code L-1216C47A --query "Quota.[QuotaName,Value]" --output text
}

step_3() {
aws rds describe-global-clusters --query "GlobalClusters[].GlobalClusterMembers[].[DBClusterArn,IsWriter]" --output table
}

# print a step that has to be run by hand, instead of running it
by_hand() {
  echo "  (run this one yourself: $1)"
  sed 's/^/    /'
}

RESULTS=()
run_step() {
  local n=$1 start=$SECONDS code
  printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
  "step_$n"
  code=$?
  RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}

summary() {
  echo
  echo "== summary"
  local r
  for r in "${RESULTS[@]}"; do echo "  $r"; done
}

case "${1:-}" in
  -h|--help) sed -n '2,6p' "$0"; exit 0 ;;
  --list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac

[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
  if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
    echo "there is no step '$n'; try --list" >&2
    exit 2
  fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done

Then make it executable and run it:

chmod +x lab.sh
./lab.sh --list     # the steps
./lab.sh            # every step, then a summary of exit codes and times
./lab.sh 2 3        # only steps 2 and 3

5. Learn the basics behind it

New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.

If you remember nothing else

Design exercise

An online retailer wants to survive the loss of a Region. Design the multi-Region approach for its checkout, catalogue, and reporting services.

Clarifying questions to ask

What RTO and RPO does each service need, and who signs them off? Which pattern does each use? How is data replicated, and what is the real RPO? How is traffic shifted, and who decides? How is capacity guaranteed? How often is it rehearsed, and what is measured?

Rough sizing

Say checkout loses $60,000 an hour when down, the catalogue $10,000, reporting nothing urgent; peak of 2,000 orders a minute; two EU Regions.

Shape of the answer

Checkout: warm standby or active/passive with Aurora Global Database (lag under a second), Global Accelerator, quotas at 120% of peak, a one-command failover by the incident commander, quarterly drills; catalogue: active/active for reads from replicated storage and caches, writes homed in one Region; reporting: backup and restore with a 24-hour RTO; idempotency keys on checkout writes; failback rehearsed; costs reported per service.

Trade-offs to name

Active/passive at full scale doubles checkout's compute cost and removes scaling risk; warm standby is cheaper and depends on quotas and autoscaling; active/active reads are cheap to add, active/active writes are expensive to get right.

Failure modes and how to troubleshoot them

Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.

ScenarioWhereEffectWhat goes wrong
Active/active, no conflict planHop 7: Write conflictsBreaksUsers are routed by latency, so the same customer's requests can reach either Region. Order updates and stock decrements happen in both within the replication lag.
Standby cannot scaleHop 6: CapacityBreaksFailover starts on time, but eu-central-1's vCPU and Elastic IP quotas are still at defaults. Scaling stops at about 20% of peak capacity, and other customers are failing over to the same Region.

How to troubleshoot

  1. Write down the symptom and when it started: what users see, which number moved, and what changed just before (a deploy, a config change, traffic).
  2. Walk the path in order, from the first hop to the last: RTO and RPO → Pattern → Data replication → Global routing → Failover decision → Capacity → Write conflicts → Runbook and drills → Failback. The first hop whose evidence is wrong is where to dig.
  3. At that hop, run the read-only check from the diagram or the lab first; change nothing until the evidence points at a cause.
  4. Fix the smallest thing that restores service, or roll back the last change, and confirm the symptom is gone with the same check.
  5. Write down what you found and the check that would have caught it sooner, so the next person starts there.

Architecture review checklist

Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.

  1. Business outcomeWhich result for users or the business does this design serve, and which number shows it is working?
  2. SecurityWho and what can reach each part, how is identity proven, and how is data protected in transit and at rest?
  3. ReliabilityWhat is the target (SLO), which single failures does the design survive, and how was that tested?
  4. PerformanceWhat latency and throughput are required at peak, and where is the first bottleneck?
  5. OperationsHow is it deployed, observed, and changed safely, and who is paged when it breaks?
  6. CostWhat does it cost per month and per unit of work (request, tenant, model call), and what grows the bill?
  7. SustainabilityWhich resources sit idle, which region and hardware does it run on, and what can scale to zero?
  8. GovernanceWhich policies, guardrails, and compliance rules apply, and how are they enforced in code?
  9. OwnershipWhich team owns each component, its budget, and its on-call, and where is that written down?
  10. Failure and recovery planWhat is the RTO and RPO, what is the runbook for a region or dependency loss, and when was it last rehearsed?

References and review

The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.

Last updated . Next review due by November 2027. Found something out of date? Tell me.

Saved on this device, in this browser.
Next in this series · Lesson 160
SaaS and Multi-Tenant Architecture: Isolation, Noisy Neighbours, and Cost per Tenant

A SaaS product serves many customers (tenants) from one system. The central design choice is isolation: a silo gives each tenant its own stack (strong isolation, high cost), a pool shares everything (cheap, and every tenant's…

Go to Lesson 160 →

Or browse the full course from the Lessons index.