skip to content

learn.smmeyer.devsystem-design10

system-design/10

global scale · deep · ~3h practice

Multi-region & global systems

outcome

Balance latency, availability, residency, and conflict across regions.

Plan a practice session · ~3h including exercises
Read + trace the worked example
25 min
Assignment + constraint variations
100 min
Timed drill + repeated explanations
35 min
Closed-book recall + self-review
20 min

This is a suggested practice budget, including drawing, variations, and repeated drills. Reading is the first block. Split the work across sessions and use the rubric to judge when to move on.

why this matters

Multi-region is not ‘add another map pin.’ It introduces replication lag, split-brain risk, evacuation procedures, and product-visible conflict semantics.

coverage

  • Routing: geo/latency routing, health, session affinity.
  • Placement: home region, data residency, sovereignty.
  • Replication: global databases, lag, read locality.
  • Writes: single-writer, multi-leader, active-active.
  • Conflict: last-write-wins, version vectors, domain merge.
  • Evacuation: failover, dependency mapping, capacity, disaster exercises.

mental model

Route users near compute while giving each mutable datum a clear write authority.

  1. 1 →Edge

    Nearest healthy

  2. 2 →Home

    Write authority

  3. 3 →Replicate

    Async copies

  4. 4 →Evacuate

    Capacity + replay

Read in numbered order: edge → home → replicate → evacuate.

lessons

01Choose a write topology per domain

A home-region model gives a single authority and simple conflict behavior at the cost of remote write latency. Multi-leader improves local writes but forces merge semantics. Some data—preferences—merges naturally; other data—unique ownership—does not.

Assign write ownership per data domain. A single home region simplifies ordering for an account but adds remote-write latency. Active-active writes let multiple regions accept changes, so you must define conflict handling. Append-only events with globally unique IDs are easier to merge than two regions both decrementing the last available item. Geography does not remove the invariant.

Walk through a regional partition. Which region can still acknowledge writes? What do remote readers see? If two sides both accept conflicting updates, how will you reconcile them? A last-write-wins timestamp policy can discard a legitimate change and depends on clock behavior; it is a product decision with consequences, not a generic correctness repair.

Reads can often be local even when writes have a home, but read-your-writes then needs a strategy such as temporarily routing to the owner or waiting for a replication position. Record data ownership in routing metadata and design ownership changes as a protocol. A DNS change alone cannot safely transfer authority over mutable state.

  • Read replicas reduce latency but expose lag
  • Session routing can preserve read-your-writes
  • Keep control plane failure separate from data plane

02Residency constrains architecture

Data residency can dictate storage and processing location, backup geography, and operator access. Make the policy explicit before global replication.

Treat residency as a supplied constraint on particular data classes. Customer documents, account metadata, usage logs, backups, and derived embeddings may have different placement rules. Create a table showing allowed locations for each class and every processor. A primary database in an allowed region does not help if its backup or diagnostic export leaves that boundary.

Follow the whole lifecycle: ingestion, replication, support access, processing, backup, deletion, and disaster recovery. If a region becomes unavailable and data cannot leave its allowed geography, recovery must use permitted capacity or accept downtime. The design should expose that tradeoff before an incident. Obtain the applicable requirements from the product and legal owners rather than inferring law from a region name.

Deletion also propagates across copies and derived indexes. Keep versioned deletion intent so an older replication event cannot resurrect data. Define what remains in backups, who can restore it, and how restored data is brought back into compliance with deletion records. This is a recovery workflow, not just a delete statement.

  • Classify data before placing it
  • Keep region-independent identifiers
  • Know which dependencies are actually regional

03Evacuation is a capacity event

Failover succeeds only if the destination has capacity, credentials, data, configuration, and tested runbooks. DNS/edge routing is the smallest part. Plan write fencing, backlog replay, and failback.

Capacity must exist where traffic will land after failure. Suppose two regions normally handle 400 requests/s each and each can serve at most 600 at the required latency. Losing one leaves 800 requests/s for a 600-capacity survivor. The healthy region still needs load shedding, degraded behavior, or more reserved capacity. Steady-state utilization alone concealed the risk.

Failover has several decisions: detect a problem, establish the old writer cannot safely continue, promote a valid replica, route traffic, and validate product behavior. With asynchronous replication, identify the last durable position and any accepted writes that may be missing. Refuse unsafe writes or expose a recovery state instead of quietly pretending the new replica contains all history.

Failback needs equal care. The recovered region may contain divergent state, stale jobs, or old credentials. Reconcile data, rejoin replication, warm dependencies, and shift traffic gradually. Practice the procedure and measure RTO and RPO with actual failure injection. A diagram with two regions is only a starting hypothesis about recoverability.

  • Measure replication lag
  • Exercise partial and full-region loss
  • Prevent two regions from believing they are sole writer

worked example

Fail over without forgetting the missing writes

Region A accepts 100 writes/s and asynchronously replicates to B. B is 20 seconds behind when A becomes unreachable.

  1. At that assumed steady rate, up to roughly 2,000 recent writes may be missing at B. Replication lag is exposure, not proof that all those writes are permanently lost.
  2. Decide whether to wait, enter a read-only mode, or promote B with an accepted recovery-point gap. State the product consequence.
  3. Fence A before accepting conflicting writes at B, or use an ownership protocol that prevents both from acting as primary.
  4. After recovery, reconcile missing or conflicting records and plan failback. Verify that B has capacity for evacuated traffic and dependencies.

Design decision: Choose failover behavior from the RPO, RTO, and ownership contract rather than routing health alone.

Limit: Real lag is uneven and may be reported late. DNS changes do not move state, revoke old authority, or add capacity.

Teaching scenario · traffic, prices, and capacity values are illustrative.

assignment

Produce: A regional topology, per-data-class residency table, and failover/failback runbook.

Paper, a text editor, or a spreadsheet is enough. Model access and paid services are optional.

  1. Specify ownership, replication, latency, RPO, and RTO for the critical write path.
  2. Simulate a region loss and account for in-flight requests, missing writes, and capacity in the survivor.
  3. Run a second tabletop for failback, including reconciliation and a rollback if promotion was mistaken.

Change a constraint

  • The application requires zero accepted-write loss.
  • EU tenant data and its backups must remain in the EU; treat this as a supplied product constraint.

Self-review rubric

  • State authority is explicit during a partition.
  • The failover plan accounts for data and capacity.
  • Residency includes logs, backups, and operational paths.

If a criterion is missing, revise that part of the artifact before rating your practice below.

Compare a sample artifact after your attempt

One defensible answer under these assumptions. Compare the reasoning and checks with your work; other designs can satisfy the same contract.

A writes 100 operations/s, B trails by 20 seconds, and residency requirements are supplied product constraints. An unreachable A is not automatically proven dead.

Topology: one write owner/domain; async replica; fenced promotion
At-risk interval: 100 writes/s × 20 s = roughly 2,000 writes
Class       primary/replica/backup/processing
EU bodies   EU / EU / EU / EU
Routing IDs permitted locations only, with no document content
Failover: fence old owner → establish durable position → assess missing ops
          → promote/reroute → reconcile → validate
Failback: reconcile divergence → rejoin → warm → gradually return traffic

The 2,000 figure assumes a stable write rate and lag interval; it bounds an illustrative exposed window, not a measured loss count. Zero accepted-write loss requires a stronger acknowledgement/recovery design or reduced write availability. Residency applies to backups, logs, and processing as well as the primary. Record the allowed placement per class instead of inferring a legal rule.

Check your artifact

  • Promotion does not create two unfenced writers.
  • RTO and RPO are separately stated and tested.
  • The survivor has capacity, and restored data cannot resurrect previously deleted records unnoticed.

A tempting mistake: Changing DNS does not reconcile missing writes or establish exclusive ownership. Those are separate recovery steps.

cumulative practice

Relay · build and evolve a private file service

Project brief

Keep one design document for Relay, a tenant-aware file service. Start with 100k daily users, ten downloads per user/day, 10k uploads/day, 1 MB typical bodies, 30-day retention, and a 5× download peak. Files are private to workspaces. Treat these as fictional planning assumptions. Later chapters add previews, recovery, regional constraints, compute, and an assistant. Record each change rather than replacing the earlier version; the final review combines the whole packet. These activities share the chapter's existing practice budget.

Keep one project document across this track. Reconstruct earlier reasoning before opening notes, then revise the same artifact. Use part of the assignment and review budget for this work. If you enter mid-course, sketch the earlier decisions first using the linked chapters.

Add to your project: Relay's regional ownership, permitted-placement table, and evacuation plan.

Relay's peak 58 downloads/s is split evenly across two regions. Each can handle 40/s at the latency target. Recall the distinction between RPO and RTO, calculate the survivor's shortfall, and state how private access and writer ownership survive a region loss.

Compare cumulative reasoning after your attempt

The survivor needs 58/s but supports 40/s, leaving an 18/s shortfall. Reserve more capacity or reject/degrade within an explicit policy; optional previews can yield resources only if the relevant bottleneck is shared. Fence metadata ownership before promoting, assess replicated state for accepted-write loss, and retain tenant checks. Regional copies and backups must obey the supplied placement table even during recovery.

Keep your first attempt and revision together. If your answer differs, identify the assumption or mechanism that explains the difference before rating your recall.

senior signal

Frame global design as a product choice: “Conversation reads may tolerate seconds of lag; billing ledger ownership remains single-writer.”

failure patterns

  • Active-active without domain-specific conflict resolution
  • Failover into a region with no spare capacity
  • Ignoring data residency in backups and logs
  • Assuming DNS change equals recovery

knowledge checks

Start with these quick checks, then explain the closed-book questions in your own words.

  1. 01Which data is easiest for active-active writes?

    select an option to check your answer

  2. 02What often dominates region failover?

    select an option to check your answer

closed-book recall

Close the worked example and explain these from memory. Answers are self-reviewed. Drafts stay on this page; save anything you want to keep in chapter notes.

Rate the assignment and recall together

Use the assignment rubric as evidence. Completion is your own judgment; this score schedules practice.

interview drill

Design global conversation storage for users who travel, with EU residency and a 10-minute regional RTO.

  • EU residency
  • mobile users
  • 10m RTO
  • ordered messages
compare a strong approach after your attempt

Assign each workspace a compliant home region; route writes there and serve local replicas where policy permits. Use sequence IDs from the home writer and session tokens for read-your-writes. Pre-provision paired failover regions inside residency boundaries, fence the old writer, promote, and replay buffered writes before failback.

Compare decisions and failure behavior, then repeat with a changed constraint. Keep your own wording.

Use the timed mock workspace →

references

Sources offer deeper context. Provider capabilities and API contracts can change; check current official docs before implementing.

notes

saved locally