InterviewKata
System design · Module 27 of 29 · Level 5: Production and architecture

Deployment, multi-region and disaster recovery

Most outages are caused by changes (Module 04), and the worst ones by losing a whole data centre or region. This module covers both ends: how to ship changes many times a day while limiting the damage of a bad one, and how to design for a region going dark, from "we restore from backup in a day" to "users never notice". The key numbers are two: how much data you can lose, and how long you can be down.

1. The idea

A restaurant chain changing its menu doesn't swap every kitchen at once; it tries the new dish in one branch, watches the reactions, then rolls it out, and keeps the old recipe cards handy. It also keeps copies of its recipes and supplier lists off-site, and decides in advance whether a fire at headquarters means "closed for a week" or "the second kitchen takes over by lunchtime".

Shipping code

Release strategies

StrategyHowBlast radius of a bad releaseRollback
All at onceReplace every instance togetherEveryoneRedeploy the old version: minutes, with an outage
RollingReplace instances a few at a time, behind the load balancerGrows as the rollout proceedsRoll back the same way
Blue-greenRun the new version (green) beside the old (blue); switch traffic in one stepEveryone, but only after testing greenInstant: switch back to blue
CanarySend 1%, then 5%, 25%, 100% of traffic to the new version, checking metrics at each stepThe canary's shareAutomatic, when metrics degrade
Feature flagShip code switched off; turn it on for staff, then a percentage of usersWhoever has the flag onFlip the flag, no deploy

Two numbers for disasters

2. How it works

A canary that catches a bad release

Going multi-region

Four disaster-recovery strategies

AWS's disaster-recovery whitepaper names four, from cheapest and slowest to most expensive and fastest. Pick by the RPO and RTO each workload really needs (try the chooser in section 3):

StrategyWhat's running in the recovery regionTypical RPOTypical RTO
Backup and restoreNothing; backups are copied thereHours (since the last backup)Hours to a day
Pilot lightData replicated; core infrastructure defined but switched offMinutesTens of minutes to hours
Warm standbyA scaled-down but working copy of everythingSeconds to minutesMinutes
Multi-site active-activeFull capacity, serving usersNear zeroNear zero

Backups you can trust

Backup vs disaster recovery

The two get treated as one thing, but they answer different questions. A backup answers "can we get the data back as it was?" Disaster recovery answers "can we keep the service running when a whole site is gone?" You need both: a perfect standby region happily replicates a DROP TABLE, and a perfect backup still leaves you down for a day while you rebuild servers to restore it onto.

BackupDisaster recovery
Protects againstMistakes, bugs that corrupt data, ransomware, a bad migrationLosing a data centre or region: fire, power, a cloud outage
What it isCopies of the data from the past, kept somewhere separateA plan plus infrastructure: where traffic goes, who decides, in what order things start
Measured byHow far back you can go, and how long a restore takesRPO and RTO for the whole service
Proved byRestoring it, regularlyFailing over for real, in a scheduled exercise

RPO and RTO are easiest to see on a timeline. The disaster happens in the middle. Everything written in the red stretch before it is lost; the amber stretch after it is downtime. Pick a strategy:

3. Try it yourself

How many users does a bad release hit?

A release has a bug that makes 20% of requests fail. Choose the strategy and how long it takes to notice.

10 min
1M

Model: rolling takes 30 minutes for the whole fleet; canary holds at 1% for 15 minutes and 10% for 15 minutes with automatic rollback when errors rise; blue-green switches everyone at once and switches back in a minute; detection time is how long until a human or alert notices (canary's automated check takes 3 minutes). Each user makes about 2 requests a minute.

Which disaster-recovery strategy?

15 minutes
1 hour
StrategyMeets RPO?Meets RTO?Relative cost

4. Trade-offs

Speed vs safety of releases

Canaries and staged rollouts take longer to reach everyone, but catch most bad releases on a sliver of traffic. Fast fixes still need a fast path, with the same checks.

Multi-region costs a lot

Double (or more) infrastructure, cross-region data transfer, harder data consistency, and many more ways to be partially broken. Do it for workloads whose RTO and RPO truly need it.

Per workload, not per company

Checkout might need warm standby; the analytics warehouse can restore from backup tomorrow. Tier your systems.

Failover is a feature

A failover nobody has practised usually fails. Run game days: fail over on purpose, on a schedule, and fix what breaks.

5. In real systems

In an interview, deployment rarely needs more than a sentence ("canary releases with automatic rollback on SLO metrics, feature flags for risky changes"). Multi-region comes up when the prompt says "global" or "must survive a region failure": state active-passive or active-active, how data replicates, the RPO you accept, and how users are routed.

Lessons from real outages

Most big outages start with a change. Two well-documented ones show why rollouts and failover need care:

IncidentWhat happenedThe lesson
GitHub, 21 October 2018A 43-second network partition during maintenance made the database failover tool promote primaries on the US West Coast. Both coasts then held writes the other lacked, and failing back safely took 24 hours of degraded service.Automatic failover across regions can create split brain (Module 21); require quorum, prefer staying in-region, and practise failover with fault injection.
CrowdStrike, 19 July 2024A security content update with a field-count mismatch made the Windows sensor read out of bounds and crash at boot. It went to all hosts at once; Microsoft estimated about 8.5 million Windows devices were affected.Staged rollouts and canaries apply to data and configuration, not just code; validate inputs; let customers control rollout timing.

The technologies up close

The default answer in an interviewDeployment needs one sentence: canary releases with automatic rollback on error rate and latency; risky features behind flags; infrastructure in Terraform; database changes expand-and-contract. When the prompt says global or "survive a region", state active-passive or active-active, the RPO and RTO, how data replicates, and how traffic moves. And always: backups with point-in-time recovery, tested.

Feature flags

The default · separate deploy from release

A runtime switch around new code: the code ships dark, then is turned on for staff, then 1% of users, then everyone, without a deploy. Turning it off is the fastest rollback there is.

How it works

  • Evaluation: SDKs download the flag rules and evaluate them locally in microseconds (by user, tenant, country, percentage), streaming updates; no network call per check.
  • Percentage rollouts hash the user ID so each user consistently sees the same variant.
  • Kinds: release flags (short-lived), operational kill switches (long-lived), experiments (A/B tests), and entitlements (plan features).
  • Debt: every flag is a branch in the code. Remove release flags once they reach 100%.

Status today (checked October 2026)

LaunchDarkly, Unleash, Flagsmith, GrowthBook, Statsig, cloud services (AWS AppConfig, Firebase Remote Config) and in-house tables. OpenFeature, a CNCF incubating project, standardises the SDK API across vendors.

Use it when

  • Risky changes, gradual rollouts, kill switches for expensive features
  • Trunk-based development: merge unfinished work behind a flag

In the interview

The new ranking ships behind a flag: staff first, then 1%, 10%, 100%, watching error rate and latency; turning the flag off is the rollback.

🚩 Red flags
  • Hundreds of stale flags nobody dares delete.
  • A remote call per flag check on the request path.

Rolling, blue-green and canary on Kubernetes

The default deploy strategies

Three ways to replace running code. Rolling swaps pods a few at a time; blue-green runs a full new copy and switches traffic at once; canary sends a small share of traffic to the new version and grows it while metrics stay healthy.

How it works

StrategyHowRollbackCost
RollingDeployment replaces pods gradually (maxSurge, maxUnavailable); readiness probes gate trafficRoll the Deployment back (another rolling update)None extra
Blue-greenA full second environment; flip the Service or load balancerFlip back: seconds2× capacity during the switch
Canary1% → 5% → 25% → 100% by traffic weight, with automated metric analysisAutomatic abort on bad metricsSmall; needs good metrics

Both versions run side by side in every strategy, so APIs, events and database schemas must be compatible with old and new code at once.

Status today (checked October 2026)

Built-in Deployments do rolling updates. Argo Rollouts and Flagger add blue-green and canary with automatic analysis (querying Prometheus or Datadog), using a service mesh or Gateway API for traffic weights.

Use it when

  • Rolling for routine changes
  • Canary with automatic rollback for user-facing services at scale
  • Blue-green when you need an instant, whole switch

In the interview

Canary through Argo Rollouts: 5% for 10 minutes, automatic analysis on error rate and p99, then 25%, 50%, 100%.

🚩 Red flags
  • No readiness probe: pods get traffic before they're ready.
  • A canary nobody measures.

Infrastructure as code: Terraform and friends

The default for cloud resources

Cloud resources (networks, databases, queues, permissions) declared in files kept in Git, reviewed like code, and applied by a tool that compares what's declared with what exists.

How it works

  • Plan, then apply: Terraform reads its state (what it created before), queries the cloud, and shows a plan of creates, updates and destroys before changing anything.
  • State lives in a remote backend with locking (S3, GCS, Terraform Cloud) so two people can't apply at once.
  • Drift: someone changes a setting by hand; the next plan shows it and puts it back.
  • Modules package repeatable pieces ("a service with its database and alarms").

Status today (checked October 2026)

Terraform moved to the Business Source License in 2023 and HashiCorp became part of IBM in 2025; OpenTofu, the open-source fork, joined the CNCF in April 2025. Alternatives: Pulumi (general-purpose languages), AWS CDK and CloudFormation, Azure Bicep, and Crossplane (cloud resources managed from Kubernetes).

Use it when

  • Every cloud environment beyond a demo
  • Recreating a region or an environment from scratch

In the interview

All infrastructure is Terraform in Git, applied by CI after review, so a second region is mostly a new set of variables.

🚩 Red flags
  • Hand-made production resources nobody can recreate.
  • Secrets in state files stored unencrypted.

GitOps

Situational · Kubernetes deploys

The desired state of each environment is a Git repository; an agent inside the cluster continuously makes the cluster match it. A deploy is a commit; a rollback is a revert.

How it works

  • Pull, not push: CI builds and tests an image and updates a version in the config repo; the in-cluster agent pulls and applies it. CI needs no cluster credentials.
  • Continuous reconciliation: manual changes in the cluster are detected and reverted (or flagged).
  • Audit for free: Git history says who changed what, when, and who approved it.

Status today (checked October 2026)

Argo CD and Flux are both CNCF graduated projects and the common choices; they pair with Argo Rollouts or Flagger for progressive delivery.

Use it when

  • Kubernetes with many services or clusters
  • Teams that need an audit trail of every production change

In the interview

CI publishes images; Argo CD syncs each environment from its Git repo, so every production change is a reviewed commit.

🚩 Red flags
  • kubectl apply from laptops in production.

Global failover

Situational · surviving a region

Moving traffic and writes to another region when one fails. Traffic is the easy half; data is the hard half, because the standby only has what was replicated.

How it works

  • Traffic: DNS failover with health checks (TTLs of 60 s or less), anycast global load balancers, or a routing control you flip deliberately (AWS Application Recovery Controller).
  • Data: asynchronous cross-region replicas lose the last moments of writes (Aurora Global Database replicates with typically about a second of lag); synchronous options give an RPO of zero at the cost of write latency (Spanner, CockroachDB, DynamoDB global tables with multi-region strong consistency, GA since June 2025).
  • Who decides? Fully automatic regional failover risks split-brain on a flaky network (GitHub 2018). Many teams automate detection and make the final switch a single, rehearsed human decision.
  • Rehearse: game days that actually fail over; a plan never run doesn't work.

Status today (checked October 2026)

All major clouds provide the pieces: Route 53, Cloud DNS and Azure Traffic Manager health-checked routing, global load balancers, cross-region database replicas and global tables.

Use it when

  • Stated requirements to survive a region loss
  • Regulated or revenue-critical services with low RTO

In the interview

Active-passive: Aurora Global Database replicating to a second region with about a second of RPO; failover is a rehearsed runbook flipped through ARC, target RTO 15 minutes.

🚩 Red flags
  • Never tested failover.
  • Automatic promotion on any blip, causing split-brain.

Backups and point-in-time recovery

The default · the last line of defence

Replicas copy mistakes instantly; backups let you go back. Point-in-time recovery (PITR) restores a database to any second in a window, such as one minute before a bad migration.

How it works

  • How: periodic full snapshots plus a continuous archive of the write-ahead log (WAL). To restore to 14:31:59, start from the snapshot before it and replay the log up to that moment.
  • Restore makes a new database, so a restore takes time proportional to data size and log replayed: measure it, because that's your real RTO.
  • 3-2-1: three copies, two kinds of storage, one off-site; for ransomware, an immutable or separate-account copy (S3 Object Lock, backup vault locks).

Status today (checked October 2026)

Managed databases do this for you: Amazon RDS and Aurora restore to any second within a retention of up to 35 days; Cloud SQL, Azure Database and others are similar. For self-managed PostgreSQL, pgBackRest, Barman and WAL-G handle base backups and WAL archiving.

Use it when

  • Every database holding data you can't regenerate

In the interview

PITR with 14 days of retention, plus daily snapshots copied to a locked vault in another account and region; we test a restore monthly.

🚩 Red flags
  • "We have replicas, so we don't need backups": a DROP TABLE replicates too.
  • Backups never restored in a test.

One region, on purpose

The default for most products

Running in several regions is often presented as the mature choice. For most products it is the expensive one: roughly double the infrastructure, cross-region data costs, harder consistency, and failover machinery that must be tested or it won't work. One region spread over three zones, with a tested way back, is the right answer more often than not.

How it works

SignalPoints to one regionPoints to several
Downtime the business can accept if a whole region failsHours (a region-wide outage is rare)Minutes, written into contracts
Where users areMostly one continentSeveral continents, and latency matters (Module 01)
Data rulesOne jurisdictionLaws require data to stay in each country or region
TeamOne team, one on-call rotationA platform team that can run and rehearse failover

What a good single-region setup still has: every tier spread across three zones; backups copied to a second region and restored there on a schedule; infrastructure as code that can rebuild the stack in that region; and a written, timed plan saying how long that would take. That is the backup-and-restore or pilot-light strategy above, chosen deliberately.

Say when you'd change it: "If a contract demands under an hour of downtime for a regional failure, or if we open in Asia, we add a second region, starting with read traffic."

Status today

Cloud providers design each region as several isolated zones so that a single-region, multi-zone deployment survives the common failures (a data centre, a power feed, a network link).

Use it when

  • Most products, most of the time
  • Startups and new products

In the interview

One region, three zones, with backups restored weekly in a second region. A regional outage would cost us a few hours, which the business accepts; a second region would double the cost for a rare event.

🚩 Red flags
  • Active-active across regions for a product with one country's users.
  • A DR plan that has never been run.

Game days: rehearsing failure on purpose

Situational · before you rely on a recovery plan

A failover or restore that has never been run is a hope, not a plan. A game day is a scheduled exercise where the team breaks something deliberately, with everyone watching, to find out whether recovery works and how long it takes.

How it works

  1. Pick one question. "Can we restore the orders database from last night's backup in under 2 hours?" "Does traffic move when we turn off zone B?"
  2. Write down what you expect, and what will make you stop early (errors above 1%, a real incident elsewhere).
  3. Start small. Staging first; in production, a fraction of traffic or a quiet hour, with the people who'd normally respond.
  4. Run it and time every step, including the slow human ones: finding the runbook, getting access, waiting for approvals.
  5. Fix what you found and run it again. The usual findings are unglamorous: an expired credential, a missing permission, a step that only one person knew.

Good first exercises: restore a backup into a fresh database and check it; turn off one zone; make a dependency slow (add 2 seconds) rather than down; fail over the primary database; let a certificate expire in staging.

Status today

Widely practised since Netflix's Chaos Monkey and Amazon's GameDay exercises; tools such as AWS Fault Injection Service, Azure Chaos Studio, Gremlin and Chaos Mesh inject failures safely (Module 24).

Use it when

  • Before trusting any failover or restore plan
  • After big changes to infrastructure or the team

In the interview

Our restore target is 2 hours; we rehearse it every quarter by restoring last night's backup into a fresh database and timing it. The last run took 3 hours, mostly waiting on access, so we fixed that first.

🚩 Red flags
  • "Backups are fine" with no restore ever timed.
  • Breaking production without abort criteria.

6. Remember it

Memory hook: "Taste in one branch; keep the recipes off-site"Release to a small slice first and roll back automatically; keep tested, off-site copies of data and decide in advance how much you can lose (RPO) and how long you can be closed (RTO).
How this hook works: what "Taste in one branch; keep the recipes off-site" means

What the slogan means, phrase by phrase

"Taste in one branch"
Canaries, staged rollouts and feature flags: expose a change to a small share of traffic, watch the metrics, and roll back before most users ever see a bad version.
"keep the recipes off-site"
Backups and replicas in another region or account, immutable and tested, so a lost region or a bad delete is recoverable.
(and decide how long you can be closed)
RPO and RTO per workload pick the strategy: backup and restore, pilot light, warm standby, or active-active.

Why this picture fits: a chain of restaurants deals with both everyday changes and rare catastrophes; the disciplines are the same in software.

The story → the concept

Restaurant chainSystem
Trying a dish in one branchA canary release
Taking it off the menu quicklyAutomatic rollback, or flipping a feature flag
Recipe copies in a safe elsewhereOff-site, immutable backups
A second kitchen that's kept warmWarm standby in another region
Two kitchens both serving all dayActive-active
"Closed for a week" vs "open by lunch"RTO

Watch it on an example

  1. A payments company tiers its systems: payment processing (RPO ≈ 0, RTO 5 minutes), merchant dashboard (RPO 15 minutes, RTO 1 hour), reporting (RPO 24 hours, RTO 1 day).
  2. Payments runs active-active across two regions with synchronous replication for the ledger; the dashboard runs warm standby; reporting restores from backups.
  3. Every release goes 1% → 10% → 100% per region, with rollback on error-rate or latency SLO burn.
  4. Each quarter, a game day fails one region over on purpose; the measured times are the real RTOs.

The trap it saves you from

A "highly available" architecture diagram with no measured recovery time, and releases that reach every user before anyone checks a graph.

It still works when…

The change is a new AI model or prompt (Module 29): shadow it, canary it on a slice of traffic, compare quality and cost metrics, and keep the old one ready to switch back.

7. Common mistakes

Never testing a restoreBackups that fail to restore, or take three days, are discovered during the disaster. Restore on a schedule and time it.
Releasing to everyone at onceA bad release hits every user before detection. Stage rollouts and automate rollback on metrics.
Hidden single-region dependenciesA second region is useless if login, DNS management or a config service lives only in the first. Map every dependency.
Schema changes that break the running versionDuring a rollout, old and new code run together. Make every migration compatible with both.
Over-building DRActive-active for an internal reporting tool wastes money and adds complexity. Match the strategy to the workload's RPO and RTO.

8. Design exercise (25 minutes)

  1. Design a release process for a mobile banking API: environments, checks, canary steps, the metrics that trigger rollback, and how database migrations fit.
  2. Tier the systems of an e-commerce site (checkout, catalogue, search, recommendations, analytics, admin) with an RPO and RTO each, and pick a DR strategy for each.
  3. Plan multi-region for a social app with users in the US, EU and India and EU data-residency rules. Active-passive or active-active? Where does each user's data live?
  4. Write a game-day plan: what you break, what you measure, what "success" means.
  5. Write it down: RPO vs RTO, and the four DR strategies in order.

9. Self-check quiz

What does RPO measure?

Recovery point objective: the age of the newest data you're guaranteed to recover. RTO is the downtime.

Which strategy limits a bad release to a small share of users and can roll back automatically?

Blue-green switches everyone at once (with fast rollback); a canary exposes only a slice while metrics are checked.

RPO of a minute and RTO of 15 minutes, at reasonable cost. Which DR strategy?

A scaled-down running copy with continuous replication can take over in minutes; backups take hours.

Why isn't a cross-region replica a backup?

A replica faithfully copies mistakes. Backups and point-in-time recovery let you go back to before them.

Why did GitHub's 43-second network partition in 2018 become 24 hours of degraded service?

Cross-region automatic failover created divergent writes; reconciling them safely took a day.

An engineer runs DELETE without a WHERE clause. Why don't read replicas save you?

Replicas protect against machine failure, not mistakes. Point-in-time recovery from backups does.

What makes rollback fastest for a risky new feature?

No build or deploy needed: the code path is switched off at runtime.

A B2B tool's users are all in Europe and contracts allow 4 hours of downtime for a regional outage. What setup fits?

Zones cover common failures; a tested restore in a second region meets a 4-hour target for the rare regional one at a fraction of the cost.

What is the main point of a game day?

Untested recovery plans fail on small things: expired credentials, missing access, unknown steps.

10. Go deeper

ResourceTimeWhy
Disaster recovery options in the cloud (AWS whitepaper)45 minThe four strategies with architectures, RPO and RTO for each.
Canary release, blue-green deployment and feature toggles (Martin Fowler's site)45 minThe standard descriptions of each release technique.
Release Engineering (Google SRE book)30 minHermetic builds, staged rollouts and configuration management at scale.
The Twelve-Factor App30 minHabits that make apps easy to deploy, scale and replace.