Prev Next

Integration / Multi Region Distributed Systems Interview questions

Last updated

1. What is a multi-region distributed system? 2. What is an active-passive multi-region architecture? 3. What is an active-active multi-region architecture? 4. What is regional failover? 5. What are RTO and RPO in disaster recovery? 6. What are the main reasons to deploy across multiple regions? 7. What is the difference between a region and an availability zone? 8. What is replication lag? 9. What is conflict resolution in multi-region systems? 10. What is last-write-wins (LWW) conflict resolution? 11. What is eventual consistency? 12. What are the types of disaster recovery standby for multi-region setups? 13. What is data residency and how does it affect multi-region design? 14. What is a health check and how does it trigger regional failover? 15. What is global traffic routing in a multi-region setup? 16. What is the difference between synchronous and asynchronous cross-region replication? 17. How does the CAP theorem apply to multi-region design? 18. Why is active-active harder to build than active-passive? 19. When should you choose active-passive over active-active? 20. Explain the execution flow of an unplanned regional failover? 21. How do you perform a safe failback to the original region? 22. How does DNS-based failover work and what are its limits? 23. How does anycast routing help with regional failover? 24. What is split brain in a multi-region system and how do you prevent it? 25. Why is last-write-wins risky when clocks are skewed? 26. How do vector clocks detect conflicts between regions? 27. How do hybrid logical clocks (HLC) help in multi-region systems? 28. What are CRDTs and why do they suit active-active systems? 29. How do quorum reads and writes work across regions? 30. How does Google Spanner provide multi-region consistency? 31. How do DynamoDB Global Tables handle write conflicts? 32. How does Aurora Global Database handle regional failover? 33. How does home-region pinning avoid write conflicts? 34. What happens to in-flight writes when a region fails mid-replication? 35. How do idempotency keys help during regional failover? 36. How do you handle user session state across regions? 37. How is read-your-writes consistency achieved across regions? 38. How do deletes and tombstones behave in multi-region replication? 39. How do you generate unique IDs across multiple regions? 40. How do you protect invariants like inventory or balances in active-active? 41. Explain how a write flows in active-active with asynchronous replication? 42. How do Raft or Paxos groups spanning regions affect write latency? 43. How do you choose the number of regions and quorum placement? 44. How does Kafka replicate data across regions? 45. How do you keep caches consistent across regions? 46. How do you run schema migrations safely in a multi-region system? 47. How do you avoid a thundering herd or cascading failure during failover? 48. How do you safely test regional failover? 49. How do you monitor replication health and troubleshoot growing lag? 50. How can you optimize the cost of a multi-region deployment?

1. What is a multi-region distributed system?

A multi-region distributed system runs the same application, and usually the same data, in two or more geographically separate cloud regions (for example us-east-1 and eu-west-1). If one region is lost, another can keep serving users.

It has four moving parts: regional compute stacks, replicated data stores, a global traffic-routing layer, and failover logic that decides which region owns what.

The price is distance. Cross-region round trips cost roughly 60-150 ms depending on the pair, so every design choice about replication and consistency is really a latency-versus-correctness choice.

  • Benefit: survives a full regional outage
  • Benefit: users hit a nearby region
  • Cost: replication lag, conflicts, higher bills
Take quiz
What is the main availability benefit of running in several regions?
It removes the need for health checks
It makes every request faster by default
It guarantees zero replication lag
The app survives the loss of an entire region
Why does cross-region distance complicate system design?
Round trips take tens to hundreds of milliseconds, forcing latency-versus-consistency trade-offs
TCP does not work between regions
Cloud providers block data from leaving a region
Regions cannot run the same code version

2. What is an active-passive multi-region architecture?

In active-passive, one region (the primary) serves all production traffic while a second region stays on standby. Data is replicated to the standby, but users are not routed there until a failover happens.

Because only one region accepts writes, there is no cross-region write conflict. That is the main reason teams pick it first.

The standby can be cold (restore from backup), pilot light (data only, minimal compute), warm (scaled-down copy running), or hot (full capacity, just not receiving traffic).

  • Pros: simple consistency model, easier to reason about
  • Cons: paying for idle capacity, failover is a rarely exercised path, async replication means some RPO
Take quiz
In active-passive, which region accepts production writes during normal operation?
The standby region, then it syncs back
Only the primary region
Whichever region is closer to the user
Both regions equally
Why does active-passive avoid cross-region write conflicts?
Conflicts are blocked by DNS
Replication is always synchronous
Writes happen in a single region at any given time
Each region has its own unrelated database

3. What is an active-active multi-region architecture?

In active-active, two or more regions serve live traffic at the same time. Each region has its own compute and a copy of the data, and usually accepts writes locally.

Users are routed to the nearest healthy region, so latency is lower and there is no cold start when a region fails: the surviving regions simply absorb its share of traffic.

The hard part is data. When two regions update the same record before they hear about each other, you get a write conflict and need a defined way to resolve it.

Aspect Active-passive Active-active
Serving traffic One region All regions
Failover Promote standby, minutes Reroute traffic, seconds
Write conflicts None Must be handled
Cost Idle standby Full capacity everywhere, but all of it used

Take quiz
What new problem does active-active introduce that active-passive avoids?
Users being routed to a backup site
Needing a health check
Needing more than one region
Concurrent writes to the same data in different regions
What happens to traffic in active-active when one region fails?
Surviving regions absorb its share of traffic
All users get errors until DNS fully expires
Traffic waits until a standby is restored from backup
The database is switched to read-only globally

4. What is regional failover?

Regional failover is the process of moving user traffic, and any primary roles such as the writable database, from a failed or degraded region to a healthy one.

  1. Detect the problem through health checks and alarms
  2. Decide whether to fail over, automatically or by a human
  3. Promote the standby (database, queues, caches) if needed
  4. Redirect traffic through DNS, anycast, or a global load balancer

Application tiers are often failed over automatically, but database promotion is commonly a deliberate decision. A wrong automated promotion can cause split brain or data loss, and flapping between regions is worse than a short outage.

The reverse move, returning to the original region, is called failback.

Take quiz
Which step comes first in a regional failover?
Resizing the standby cluster
Detecting that the region is unhealthy
Redirecting traffic
Deleting the old primary
Why is database promotion often a manual or gated decision?
Promotion is illegal without approval
Databases cannot be promoted by software
A wrong automated promotion can cause split brain or lost writes
Promotion always takes exactly one hour

5. What are RTO and RPO in disaster recovery?

RTO (Recovery Time Objective) is how long the service may be down before it must be back. RPO (Recovery Point Objective) is how much recent data you can afford to lose, measured in time.

An RPO of 30 seconds means that after a failover you may lose up to 30 seconds of acknowledged writes. With asynchronous replication, your RPO is roughly your replication lag at the moment of failure.

Metric Question it answers Driven mostly by
RTO How fast are we back? Detection time, automation, standby readiness
RPO How much data can we lose? Replication mode and lag

These two numbers choose your architecture. RTO of minutes with RPO near zero pushes you toward warm or hot standby with synchronous or near-synchronous replication.

Take quiz
An RPO of 30 seconds means:
Failover must start within 30 seconds
The system may be down for 30 seconds
Replicas can lag by exactly 30 seconds in both directions
Up to 30 seconds of recent writes may be lost
Which factor mainly determines RPO with asynchronous replication?
Replication lag at the time of failure
The number of DNS records
The programming language of the app
The size of the load balancer

6. What are the main reasons to deploy across multiple regions?

Teams go multi-region for a handful of concrete reasons, and it helps to say which one applies to you, because each leads to a different design.

  • Resilience: survive a regional outage or a bad regional change
  • Latency: serve users from a nearby region, especially for global products
  • Compliance: keep data inside a country or legal zone
  • Capacity: escape quota or capacity limits in one region
  • Blast radius: roll out risky releases one region at a time

Notice that resilience alone often fits active-passive, while latency pushes you to active-active. Compliance may forbid replicating some data at all.

Take quiz
Which goal most directly pushes a team toward active-active rather than active-passive?
Avoiding health checks
Low latency for users spread across the globe
Fewer deployment pipelines
Cheaper storage
How does multi-region help limit the blast radius of a bad release?
It prevents code from reaching production
It rolls back automatically on every request
Roll out region by region and halt if errors rise
It runs old and new code on the same host

7. What is the difference between a region and an availability zone?

An availability zone (AZ) is one or more isolated data centers inside a region, with independent power and networking. A region is a geographic area made up of several AZs connected by low-latency links, typically a few milliseconds apart.

Aspect Availability Zone Region
Scope Data center group Geographic area with several AZs
Latency between peers Low single-digit ms Tens to hundreds of ms
Protects against Rack, power, or data-center failure Regional control-plane, network, or large-scale outage
Replication Often synchronous Usually asynchronous

Multi-AZ covers most hardware failures. Multi-region is for rarer events such as a regional service outage, a bad regional deployment, or legal requirements.

Take quiz
Which failure does multi-AZ alone NOT protect you from?
One data center losing power
A rack power failure
A single server crash
An entire regional outage
Why is replication between AZs often synchronous but between regions often asynchronous?
AZ links are low latency, region links are far slower
Regions cannot use TCP
Asynchronous replication is illegal inside a region
AZs share one disk

8. What is replication lag?

Replication lag is the delay between a write being committed on the source and that write becoming visible on a replica. Across regions it is commonly milliseconds to a few seconds, but it can balloon under load.

It matters for two reasons. First, readers on a lagging replica can see stale data. Second, at failover your lag is your data loss window, so it directly sets your achievable RPO.

Typical causes are network saturation, large transactions, a single-threaded apply process on the replica, or an underpowered replica. You should alert on lag and treat a rising trend as an incident precursor.

Take quiz
At the moment of an unplanned failover, replication lag represents:
The time DNS takes to update
Data that may be lost
The number of conflicting records
Extra capacity available
Which is a common cause of growing replication lag?
Having too many DNS records
Running multiple availability zones
A single-threaded apply process on the replica falling behind a write burst
Using HTTPS on the front end

9. What is conflict resolution in multi-region systems?

A conflict happens when two regions modify the same piece of data concurrently, before either has seen the other's change. Conflict resolution is the rule that decides what the final value becomes so all replicas converge.

Common strategies:

  • Last-write-wins: highest timestamp wins, simple but lossy
  • Version vectors with app merge: detect concurrency, keep siblings, let code or user merge
  • CRDTs: data types designed to merge automatically
  • Region priority: one region always wins ties
  • Avoidance: route all writes for an entity to one home region so conflicts never occur

The best conflict resolution is the one you never need, so avoidance is usually the first option to consider.

Take quiz
What triggers a write conflict in active-active?
A health check failed once
A replica read a stale value
DNS TTL expired
Two regions update the same record before syncing
Which approach prevents conflicts rather than resolving them?
Routing all writes for an entity to a single home region
Last-write-wins
Keeping sibling versions
Using CRDT counters

10. What is last-write-wins (LWW) conflict resolution?

Last-write-wins attaches a timestamp to every write. When replicas hold different values for the same key, the value with the highest timestamp is kept and the others are discarded.

It is popular because it is trivial to implement and always converges. DynamoDB Global Tables and Cassandra both use timestamp-based LWW by default.

The downside is that it silently drops one of two concurrent updates, and it trusts clocks. Example: Region A sets phone=111 and Region B sets address=X on the same item at nearly the same moment. If LWW works per item, one whole update disappears even though the fields did not overlap.

Take quiz
What does LWW do when two regions write the same key concurrently?
Merges both values automatically
Keeps the value with the highest timestamp and discards the other
Asks the user to choose
Rejects both writes
What is the main weakness of LWW?
It never converges
It needs a third region
Concurrent updates are silently lost and results depend on clocks
It can only store numbers

11. What is eventual consistency?

Eventual consistency promises that if no new writes happen, all replicas will eventually hold the same value. It does not promise that two readers see the same value at the same moment.

This is the normal model for asynchronous cross-region replication. A write acknowledged in Region A may take milliseconds or seconds to appear in Region B.

It is not the same as being wrong. Many apps add session guarantees on top, such as read-your-writes and monotonic reads, to hide the lag from individual users.

Take quiz
Eventual consistency guarantees that:
Writes are always rejected during lag
Only one region may hold data
Every read sees the latest write immediately
Replicas converge once writes stop
What can be layered on top to hide lag from a single user?
Session guarantees such as read-your-writes
Longer DNS TTLs
Smaller database pages
More availability zones

12. What are the types of disaster recovery standby for multi-region setups?

The standard ladder, as popularised by AWS, runs from cheapest and slowest to most expensive and fastest.

Strategy What runs in the second region Typical RTO Cost
Backup and restore Only backups Hours Lowest
Pilot light Replicated data, compute switched off Tens of minutes Low
Warm standby Scaled-down full stack running Minutes Medium
Hot standby / multi-site active-active Full capacity, taking traffic Seconds to near zero Highest

Pick based on your RTO and RPO targets and on how much idle spend the business accepts. Move up the ladder only for services whose downtime cost justifies it.

Take quiz
In a pilot light setup, what exists in the second region?
Nothing at all
Replicated data with compute mostly switched off
Only DNS records
A full-scale copy taking traffic
Which strategy offers the fastest recovery at the highest cost?
Backup and restore
Cold standby
Multi-site active-active
Pilot light

13. What is data residency and how does it affect multi-region design?

Data residency means laws or contracts require certain data, often personal data, to stay within a country or legal zone. Regulations such as GDPR also restrict transfers outside a region.

It changes the architecture in three ways:

  • Data is partitioned by jurisdiction, for example EU customers live only in EU regions
  • Replication is selective, and you may not copy personal data to every region
  • Failover paths are limited, so an EU region may only fail over to another EU region

Backups, logs, analytics exports and caches are easy to forget. They can quietly copy regulated data across borders, so include them in your data-flow review.

Take quiz
How can residency rules limit failover design?
They require DNS TTL of zero
They forbid more than one region
They require failover to be manual only
Regulated users may only fail over to regions within the allowed zone
Which is an easily forgotten way residency rules get broken?
Backups and logs copied to another country
Using HTTPS
Running health checks
Choosing a bigger instance type

14. What is a health check and how does it trigger regional failover?

A health check is a periodic probe, usually an HTTP request to an endpoint such as /health, that tells a routing layer whether a region can serve traffic. After a set number of consecutive failures, for example three, the region is marked unhealthy and removed from routing.

There are two flavours:

  • Shallow: confirms the process is up, cheap and stable
  • Deep: also checks dependencies like the database, more accurate but can cause false failovers when one dependency blips

Run checks from several vantage points, so one broken network path does not look like a regional outage, and add thresholds to avoid flapping.

Take quiz
Why probe from multiple vantage points?
To make probes cheaper
So a single broken network path is not mistaken for a regional outage
To avoid using HTTP
To replace replication
What risk does a very deep health check carry?
It cannot detect crashes
It prevents replication
A brief dependency blip can trigger an unnecessary failover
It disables TLS

15. What is global traffic routing in a multi-region setup?

Global traffic routing decides which region each user request is sent to. It is implemented through DNS services such as Route 53 or Cloud DNS, or through anycast-based global load balancers such as Google Cloud Global LB, AWS Global Accelerator or Cloudflare.

Policy Routes users by Typical use
Latency-based Lowest measured latency Active-active performance
Geolocation User's country or continent Compliance and residency
Weighted Percentage split Gradual shifts, canary failover
Failover Health status, primary then secondary Active-passive

Most real systems combine them, for example geolocation for residency with health-based failover inside each zone.

Take quiz
Which routing policy suits a gradual 10 percent to 100 percent traffic shift?
Simple single-value routing
Geolocation routing
Static IP routing
Weighted routing
Which policy is best for keeping EU users inside EU regions?
Geolocation routing
Latency-based only
Round robin
Weighted routing

16. What is the difference between synchronous and asynchronous cross-region replication?

With synchronous replication the primary waits until the remote region confirms the write before acknowledging the client. With asynchronous replication it acknowledges first and ships the change afterwards.

Aspect Synchronous Asynchronous
Write latency Adds a cross-region round trip Near local latency
RPO Zero Equal to lag at failure
Availability Writes stall if the remote region is unreachable Writes continue
Typical use Ledgers, critical state Most application data

Many systems pick a middle path: synchronous within a region or between two nearby regions, asynchronous to a distant one.

Take quiz
What do you give up by choosing synchronous cross-region replication?
Consistency
Write latency and some availability
Durability
The ability to use SQL
Why does asynchronous replication allow data loss on failover?
The replica deletes old rows
DNS drops packets
The client was told the write succeeded before the remote copy existed
Writes are never sent

17. How does the CAP theorem apply to multi-region design?

Network partitions between regions will happen, so the real choice is what to give up during a partition. CP systems refuse some requests to stay consistent. AP systems keep serving, accept divergence, and reconcile later.

PACELC extends this to normal operation: if there is no partition, you still trade latency against consistency, because strong consistency needs a cross-region round trip.

  • Spanner-style systems: consistent first, pay write latency
  • Dynamo-style systems: available first, resolve conflicts
  • Active-passive with async replication: consistent in one region, stale elsewhere

In interviews, tie it to a concrete choice: which operations must be CP, such as payments, and which can be AP, such as likes.

Take quiz
According to PACELC, what is the trade-off when there is NO partition?
Region count versus DNS TTL
Throughput versus storage
Cost versus security
Latency versus consistency
During a partition, an AP system will typically:
Keep serving requests and reconcile later
Stop all reads and writes
Shut down the network
Delete the smaller partition's data

18. Why is active-active harder to build than active-passive?

Active-passive has one writer, so the data model stays simple. Active-active needs every region to write safely, which brings problems that simply do not exist with a single writer.

  • Write conflicts need a defined resolution policy
  • Invariants such as non-negative stock cannot be enforced locally
  • Ordering differs between regions, which breaks logic that assumes a single timeline
  • Testing is harder because bugs depend on timing between regions
  • Operations need per-region capacity, per-region dashboards and clean region evacuation

Many teams find that going active-active is mostly a data-modelling project, not an infrastructure one.

Take quiz
Which problem exists in active-active but not in single-writer active-passive?
Needing TLS certificates
Concurrent conflicting writes
Needing monitoring
Needing backups
Why can a non-negative stock count be hard to enforce in active-active?
Integers cannot be replicated
Regions share one clock
Two regions can each approve the last item before seeing the other's sale
Stock is stored only in DNS

19. When should you choose active-passive over active-active?

Choose active-passive when the business can tolerate a few minutes of downtime and a small data-loss window, and when the data model is hard to make conflict-free.

  • Strong invariants: payments, inventory, bookings
  • Users concentrated in one geography, so no latency win from a second region
  • Small team that cannot yet operate two live regions
  • Relational database with a single-writer design

Choose active-active when users are global, downtime cost is very high, or data is naturally mergeable or partitionable by home region.

A common path is to start active-passive with a warm standby and make parts of the system active-active later, such as read-heavy and idempotent services first.

Take quiz
Which workload is the strongest candidate for active-passive?
A read-only product catalog
A global CDN cache
A like counter
A payments ledger with strict invariants
What is a sensible evolution path for many teams?
Warm standby first, then selective active-active for easy services
Active-active everywhere on day one
Move to a single region
Never test failover

20. Explain the execution flow of an unplanned regional failover?

Here is the sequence for a primary region that suddenly becomes unavailable, using async replication and a warm standby.

flowchart TD
  A["Health checks fail in primary"] --> B["Alarm fires, incident declared"]
  B --> C{Auto or manual decision}
  C --> D["Fence old primary so it cannot take writes"]
  D --> E["Promote standby database"]
  E --> F["Scale up standby compute and warm caches"]
  F --> G["Shift traffic via DNS or global LB"]
  G --> H["Verify errors, lag and data integrity"]
  H --> I["Reconcile lost writes and plan failback"]
  1. Detect using multi-vantage health checks and error-rate alarms
  2. Fence the old primary, otherwise it may return and accept writes (split brain)
  3. Promote the replica and record the last replicated position for the RPO report
  4. Scale and warm because the standby may be sized below full load
  5. Redirect traffic gradually if possible
  6. Reconcile writes that never replicated

The order matters: fencing before promotion is what protects data integrity.

Take quiz
Why should the old primary be fenced before the standby is promoted?
To speed up replication
To stop it from accepting writes if it comes back, causing split brain
To save DNS costs
To reset TLS certificates
What is reconciled after failover completes?
The deployment pipeline
The DNS zone file
Writes acknowledged by the old primary but never replicated
The load balancer logs

21. How do you perform a safe failback to the original region?

Failback is riskier than most people expect, because the original region has stale or divergent data and must catch up before taking traffic again.

  1. Confirm the original region is truly healthy and stable
  2. Re-seed or rewind it so it becomes a replica of the current primary (for PostgreSQL, tools like pg_rewind help)
  3. Let replication catch up until lag is near zero
  4. Shift traffic back gradually using weighted routing
  5. Perform a planned, clean switchover of the writer role
  6. Keep the other region as a ready standby

Never failback during peak traffic, and never let the old primary rejoin as a writer. Prefer a planned switchover, which can achieve zero data loss because writes are paused briefly.

Take quiz
What should the original region become before failback?
An independent writer
A cold backup
A DNS-only region
A replica that has caught up with the current primary
Why is a planned switchover safer than another unplanned failover?
Writes are paused briefly so no acknowledged data is lost
It skips replication entirely
It needs no health checks
It deletes the old data

22. How does DNS-based failover work and what are its limits?

A health-checked DNS service such as Route 53 returns the primary region's IP while it is healthy. When checks fail, it starts returning the secondary region's IP instead.

The catch is caching. Total failover time is roughly detection time + TTL + resolver and client stickiness. With a 60-second TTL and 30 seconds of detection you may still see some clients for several minutes, because some resolvers and applications ignore TTL.

  • Keep TTLs low (30-60 s) on failover records
  • Avoid long-lived client connection pooling to a single IP
  • For faster shifts, use anycast or a global load balancer instead

DNS is a coarse tool: simple and widely supported, but not instantaneous.

Take quiz
Why can some users still reach the failed region after DNS has changed?
Health checks are disabled
Resolvers or clients cache old answers beyond the TTL
Regions share the same IP
DNS cannot return two IPs
Which total makes up DNS failover time?
Only the TTL
Only the health-check interval
Detection time plus TTL plus resolver and client stickiness
Only database promotion time

23. How does anycast routing help with regional failover?

With anycast, the same IP address is announced via BGP from several regions. Internet routing sends each user to the topologically nearest one. If a region withdraws its announcement, traffic moves to the next nearest region within seconds, with no DNS change.

Services like AWS Global Accelerator, Google Cloud's global load balancer and Cloudflare use this idea, so clients keep one stable IP.

  • Pro: fast, DNS-cache independent failover
  • Con: in-flight TCP connections may reset when routes change
  • Con: less explicit control than weighted DNS

Anycast fixes the redirect step only. The data and database role still need their own failover plan.

Take quiz
What does anycast allow the same IP to do?
Bypass health checks
Be stored in multiple databases
Skip TLS
Be announced from multiple regions
Why is anycast failover usually faster than DNS failover?
It doesn't depend on client or resolver DNS caches
It disables replication lag
It uses UDP only
It copies data instantly

24. What is split brain in a multi-region system and how do you prevent it?

Split brain happens when two regions both believe they are the primary and accept writes, usually after a network partition. Their data diverges and merging it later can be painful or impossible.

Prevention techniques:

  • Quorum or consensus (Raft, Paxos): only the side with a majority can accept writes
  • Fencing tokens or STONITH: forcibly stop or block the old primary before promotion
  • External witness region: a third location breaks ties
  • Manual promotion for the database, even if app failover is automatic

The essential idea is that promotion must require proof that the old primary can no longer write.

Take quiz
What defines a split brain?
Two replicas hold the same data
Two regions both act as primary and accept writes
A region has no traffic
A DNS record is missing
How does a quorum prevent split brain?
It merges conflicts at random
It makes both sides read-only forever
Only the partition with a majority can accept writes
It disables replication

25. Why is last-write-wins risky when clocks are skewed?

LWW trusts the timestamps on each write. If Region A's clock is two seconds ahead, a write made there can beat a genuinely newer write from Region B, and the newer data is thrown away without any error.

Even with NTP, drift of a few milliseconds is normal, and bad leap-second handling or VM pauses can make it worse. Fast concurrent updates are exactly where this hurts.

  • Use hybrid logical clocks for causally consistent timestamps
  • Use version numbers or conditional writes where possible
  • Avoid LWW for fields where losing an update is unacceptable, such as balances

The lesson: LWW is safe only when occasional loss of a concurrent update is acceptable.

Take quiz
What can happen if one region's clock runs ahead?
Its writes are always rejected
Replication stops completely
All timestamps are reset
Its older write can win over a truly newer write
Which field type should generally avoid LWW?
Account balances
Feature-flag toggles with infrequent changes
Profile display names
Last-seen timestamps

26. How do vector clocks detect conflicts between regions?

A vector clock is a map of counters, one per replica, attached to each version of a value. Every time a replica updates the value it increments its own entry.

To compare two versions, check every entry:

  • If one version has all counters less than or equal to the other's, it is an ancestor and can be discarded
  • If each has some larger counter, the writes were concurrent, which is a conflict
A = {us:2, eu:1}
B = {us:2, eu:2}   -> B is newer than A (A is an ancestor)
C = {us:3, eu:1}   -> C vs B: us higher in C, eu higher in B => concurrent

Dynamo-style stores keep both concurrent values as siblings and let the application merge them. The cost is metadata that grows with the number of writers.

Take quiz
When are two versions concurrent according to vector clocks?
They have the same value
Each has at least one counter greater than the other's
One region is offline
Their timestamps are equal
What does a Dynamo-style store do with concurrent versions?
Always keeps the one from the primary region
Deletes both
Keeps siblings for the application to merge
Picks the alphabetically first value

27. How do hybrid logical clocks (HLC) help in multi-region systems?

An HLC pairs a physical timestamp with a small logical counter. It stays close to wall-clock time, so it is readable and sortable, yet it never goes backwards and always respects causality.

  1. On a local event take max(local physical, last HLC physical) and bump the counter if equal
  2. On receiving a message take the max of local and message values, then bump the counter

This guarantees that if event A caused event B, then HLC(A) < HLC(B), even when physical clocks are slightly off. CockroachDB and YugabyteDB use HLC-style timestamps.

HLC improves ordering and makes LWW safer, but it does not remove the need for a conflict policy when two writes are truly concurrent.

Take quiz
What two components make up an HLC?
A region name and an IP address
A TTL and a weight
A hash and a salt
A physical timestamp and a logical counter
What does an HLC guarantee?
If event A caused B, A's timestamp is lower than B's
No two writes are ever concurrent
Replication lag is zero
Clocks are perfectly synchronized

28. What are CRDTs and why do they suit active-active systems?

CRDTs (Conflict-free Replicated Data Types) are data structures whose merge operation is commutative, associative and idempotent. Replicas can exchange state in any order, any number of times, and still converge, with no coordination.

  • G-Counter: one counter per region, merge by taking the max per region, value is the sum
  • PN-Counter: two G-Counters for increments and decrements
  • OR-Set: each add gets a unique tag, so an add concurrent with a remove wins
  • LWW-Register: single value with timestamp

They fit active-active well for counters, sets, carts and collaborative edits. Redis Enterprise Active-Active and Riak use them.

Limits: they cannot enforce invariants such as a balance staying above zero, and some carry growing metadata.

Take quiz
What property must a CRDT merge function have?
It must need a central coordinator
It must be commutative, associative and idempotent
It must always pick the highest timestamp
It must lock all replicas
What can CRDTs NOT enforce on their own?
Idempotent merges
Convergence of replicas
Global invariants such as a non-negative balance
Merging concurrent increments

29. How do quorum reads and writes work across regions?

With N replicas, a write waits for W acknowledgments and a read contacts R replicas. If R + W > N, read and write sets overlap, so a read sees the latest acknowledged write.

Across regions the question becomes which replicas count. Cassandra offers a good illustration with two data centers at RF=3 each (N=6):

Level Needs Effect
LOCAL_QUORUM 2 of 3 in the local DC Fast, but remote DC may lag
QUORUM 4 of 6 overall Crosses regions, slower
EACH_QUORUM 2 of 3 in every DC Strongest, fails if a DC is down

Most multi-region apps use LOCAL_QUORUM for latency and accept eventual consistency between regions.

Take quiz
What condition makes quorum reads see the latest acknowledged write?
N is odd
R equals 1
W equals 1
R + W is greater than N
Why do many multi-region Cassandra apps use LOCAL_QUORUM?
It avoids waiting on cross-region round trips
It requires only one replica
It disables replication
It guarantees global strong consistency

30. How does Google Spanner provide multi-region consistency?

Spanner splits data into ranges, and each range is replicated with Paxos across zones or regions. A write commits once a majority of replicas agree, so a minority of failures never loses acknowledged data.

Its second ingredient is TrueTime: a clock API backed by GPS and atomic clocks that returns a time interval with a bounded uncertainty. Spanner waits out that uncertainty (commit wait) before making a commit visible, which yields external consistency, meaning transactions appear in real-time order globally.

The trade-off is write latency. A multi-region write needs a cross-region majority round trip, and leader placement affects performance.

Take quiz
What does Spanner use to replicate each data range?
Last-write-wins
Paxos consensus across replicas
Manual backups
Gossip with vector clocks
What is TrueTime's role?
Encrypt replication traffic
Compress snapshots
Provide bounded-uncertainty timestamps so commits are globally ordered
Route DNS queries

31. How do DynamoDB Global Tables handle write conflicts?

Global Tables is a multi-active setup: any replica region accepts writes, and changes replicate asynchronously to the others, typically within about a second.

By default, conflicts are resolved with last-writer-wins using an item-level timestamp. If two regions update the same item concurrently, the later timestamp wins for the entire item, and the other change is dropped.

  • Strongly consistent reads apply only within the region that holds the latest local write
  • Design so each item has a single writer region where possible
  • Use conditional writes carefully, since they check only local state

AWS has also introduced an optional multi-Region strong consistency mode with different latency trade-offs, so check the current documentation for the details.

Take quiz
How does DynamoDB Global Tables resolve concurrent writes to one item by default?
Always favours the first region
Field-level merge
Manual review by the operator
Last-writer-wins by timestamp, per item
Which design habit reduces conflicts in Global Tables?
Give each item a single writer region
Use bigger items
Disable replication
Use random partition keys only

32. How does Aurora Global Database handle regional failover?

Aurora Global Database has one primary region that accepts writes and up to five secondary regions with read-only clusters. Replication happens at the storage layer, typically with lag under a second.

There are two failover modes:

  • Managed planned switchover: waits for secondaries to catch up, so RPO is zero
  • Unplanned failover: promote a secondary after detaching it; RPO equals the replication lag at that moment, RTO is typically minutes

Secondary regions can also forward writes to the primary (write forwarding), which gives apps a single endpoint style but still routes every write to one region.

Take quiz
How many regions can accept writes in Aurora Global Database at a time?
Any region chosen by DNS
One primary region
All regions
Two regions
Why is RPO zero for a planned Aurora switchover?
The client retries forever
Replication is turned off
Secondaries catch up before roles are swapped
Writes are copied to S3 first

33. How does home-region pinning avoid write conflicts?

Every user, tenant or account is assigned a home region. All writes for that entity go to the home region, which is the single source of truth, while other regions serve reads from replicas or act as standby.

Since no two regions ever write the same entity, conflicts cannot occur, yet the system as a whole is still active-active, because each region is home to a different share of users.

  • Needs a highly available directory that maps entities to regions
  • Remote users pay latency for writes
  • On regional failure, reassign affected entities to a new home
  • Rebalancing traffic requires careful data movement

It is how many SaaS platforms get most of the benefit of active-active without CRDTs.

Take quiz
Why does home-region pinning remove write conflicts?
It uses random IDs
It stops replication
It uses synchronous replication everywhere
Each entity is written in exactly one region
What extra component does pinning require?
A directory mapping entities to home regions
A second programming language
A tape backup
A bigger DNS TTL

34. What happens to in-flight writes when a region fails mid-replication?

With asynchronous replication, some writes were acknowledged to clients by the primary but never reached the standby. When the standby is promoted, those writes are missing from the new primary. This is the RPO gap in practice.

The old primary still holds them on disk, so when it returns you have three options: discard them, replay them as new operations, or hand them to a manual reconciliation process.

  • Capture the last replicated log position at promotion time
  • Rewind the old primary before rejoining it as a replica, never as a writer
  • Use idempotency keys so client retries do not duplicate effects
  • Use synchronous replication, or an outbox, for the few writes that cannot be lost

For regulated or financial data, produce a reconciliation report as part of every failover.

Take quiz
Why are some acknowledged writes missing after an async failover?
DNS cached them
They were never replicated before the primary failed
The standby deleted them
They were encrypted twice
How should the old primary rejoin after recovery?
As a second writer immediately
It should never rejoin or be inspected
As a rewound replica of the new primary
As the DNS authority

35. How do idempotency keys help during regional failover?

During failover, clients often retry requests whose outcome they never saw. Without protection, a retried payment could be charged twice.

An idempotency key is a unique ID the client sends with each operation. The server stores the key with the result, and a repeat request with the same key returns the stored result instead of redoing the work.

CREATE TABLE payments (
  id            BIGINT PRIMARY KEY,
  idem_key      TEXT UNIQUE NOT NULL,
  amount        NUMERIC NOT NULL,
  status        TEXT NOT NULL
);
-- retry with same idem_key hits the UNIQUE constraint and returns the existing row

The key must be stored in the same transaction as the business change, and it must replicate with the data. Otherwise the new region does not know the original attempt succeeded.

Take quiz
What does a server do when it receives a second request with a known idempotency key?
Rejects every future request
Deletes the first record
Executes the action again
Returns the earlier result without repeating the action
Why store the key in the same transaction as the business change?
So the key and the effect replicate together to the new region
To make the key shorter
To reduce DNS lookups
To disable retries

36. How do you handle user session state across regions?

If a user lands in a different region after failover, they should not be logged out unless you decide so. Options differ in cost and risk.

Approach How it works Trade-off
Stateless tokens (JWT) Session data lives in a signed token Hard to revoke, size limits
Replicated session store Sessions copied between regions Lag may cause missing sessions
Region-sticky sessions Sticky to one region, re-login on failover Simple, but failover logs users out
Global datastore One strongly consistent session DB Cross-region latency on each request

A common compromise is short-lived signed tokens plus a refresh token stored in a replicated database, so a failover costs at most a quick silent refresh.

Take quiz
Which approach carries session data inside the client token?
Replicated session store
Stateless tokens such as JWT
Region-sticky sessions
Global session database
What is a downside of region-sticky sessions?
They require synchronous replication
They never expire
Users may be logged out when their region fails over
They cannot use cookies

37. How is read-your-writes consistency achieved across regions?

A user posts a comment in Region A, then their next request lands in Region B, which has not received the write yet. They see their comment missing, a classic read-your-writes violation.

Common fixes:

  • Sticky routing: keep a user in the region where they wrote
  • Read from the write region for a short window after a write
  • Session tokens: return a version, LSN or timestamp with each write, and have any replica wait until it has applied at least that point

Cosmos DB's session consistency level and Aurora Global write forwarding use this style of token-based approach. It gives each user a consistent view without paying for global strong consistency.

Take quiz
What does a session token typically carry?
A copy of the whole database
The DNS TTL
The user's password
A version or log position the replica must have reached
Which workaround sends reads to the region where the user just wrote?
Reading from the write region for a short window
Switching to UDP
Shortening log retention
Increasing replica count

38. How do deletes and tombstones behave in multi-region replication?

A delete cannot simply remove the row, because other regions would never learn about it. Instead the system writes a tombstone, a marker that replicates like any other change.

The danger is zombie resurrection. If a tombstone is purged before every replica has received it, a stale replica can later replicate the old row back, and the deleted data returns.

  • Cassandra's gc_grace_seconds defaults to 10 days, and repairs must complete inside that window
  • Keep tombstones longer than your longest realistic region outage
  • Use soft deletes (a deleted_at column) when the history matters

This matters for compliance too, because a resurrected record might be personal data that a user asked to erase.

Take quiz
Why are deletes written as tombstones instead of removing the row?
To speed up reads
So the delete itself can replicate to other regions
To avoid using indexes
To save storage
What causes zombie resurrection?
Using HTTPS
A DNS cache expiring
A tombstone is purged before a lagging replica receives it
Too many replicas

39. How do you generate unique IDs across multiple regions?

A single global auto-increment sequence needs cross-region coordination, so it is both slow and a single point of failure. Better options avoid coordination.

Option Idea Notes
UUIDv4 128-bit random No coordination, poor index locality
UUIDv7 / ULID Timestamp prefix plus random Time-sortable, good index behaviour
Snowflake-style Timestamp + region/node ID + sequence Compact 64-bit, needs node ID assignment
Offset sequences Region 1 uses 1, 4, 7... region 2 uses 2, 5, 8... Simple but hard to add regions

For most new systems UUIDv7 or ULID is the easiest choice, while Snowflake IDs suit teams that need compact numeric keys.

Take quiz
Why is a single global auto-increment ID a problem across regions?
It cannot be numeric
It is not unique
It requires TLS
It needs cross-region coordination and becomes a bottleneck
What makes a Snowflake-style ID unique across regions?
It embeds a region or node identifier
It reuses DNS names
It uses the user's password
It is random 8 bits

40. How do you protect invariants like inventory or balances in active-active?

If stock is 1 and two regions each sell the last item concurrently, both sales succeed locally and you oversell. Replication cannot fix this after the fact.

Options, from strict to relaxed:

  1. Single writer per entity: route that product's writes to one home region
  2. Escrow / bounded counters: split 100 units into 50 per region, a region may sell only its share, and shares are rebalanced later
  3. Strongly consistent store such as Spanner for just the few critical records
  4. Compensation: accept the oversell, then cancel and apologise via a saga

Business impact decides the choice. Stock oversell may be tolerable with compensation, while a bank balance usually is not.

Take quiz
What does an escrow approach do for a stock of 100 units across two regions?
Locks the whole table in both regions
Allocates each region a share it may sell independently
Makes stock unlimited
Stops selling after 10 sales
Which option accepts the oversell and fixes it afterwards?
Strong consistency
Single writer
Compensation through a saga
Synchronous locking

41. Explain how a write flows in active-active with asynchronous replication?

Here is the typical life of a write when two regions are both writable and replicate asynchronously.

sequenceDiagram
  participant U as User
  participant A as Region A API and DB
  participant B as Region B DB
  U->>A: POST /order
  A->>A: Commit locally
  A-->>U: 201 Created
  A--)B: Replicate change (async)
  B->>B: Apply and check for conflict
  B->>B: Resolve (LWW, merge or CRDT)
  1. The request is served by the nearest region and committed locally
  2. The client gets a fast acknowledgment
  3. The change is shipped to other regions in the background
  4. Remote regions apply it, detecting conflicts with timestamps or version vectors
  5. A resolution rule decides the winning value

The user never waits for the remote region, but a conflict may only be discovered later.

Take quiz
When does the client receive its acknowledgment in this flow?
After a manual approval
After DNS updates
After every region confirms
After the local commit, before replication
Where is a conflict typically detected?
When the remote region applies the replicated change
In the load balancer
In the user's browser
Before the client sends the request

42. How do Raft or Paxos groups spanning regions affect write latency?

A consensus write commits when a majority of replicas acknowledge it. With three replicas in three regions, the leader needs one remote ack, so latency equals the round trip to the closer of the two followers, not the farther one.

That makes leader placement important. Keep the leader in the region that generates most writes, and some systems like CockroachDB let you set lease preferences.

  • Heartbeat and election timeouts must exceed WAN round-trip jitter, otherwise you get spurious leader elections
  • Followers can serve stale or lease-based reads locally
  • Losing a majority of replicas, for example two of three regions, makes the group unavailable for writes

So strong consistency across regions always costs at least one inter-region round trip per write.

Take quiz
In a 3-region Raft group, whose acknowledgment does a leader need to commit a write?
All followers
One follower, because two of three is a majority
Only the farthest follower
No acknowledgment
Why do election timeouts need to exceed WAN jitter?
To save bandwidth
To disable heartbeats
Otherwise spurious leader elections occur
To make reads faster

43. How do you choose the number of regions and quorum placement?

The two-region problem: with only two full replicas, a failure of either leaves no majority. You must either accept manual promotion with risk, or make one region the permanent tie-breaker, whose loss causes a full outage.

The usual solution is a third location, which can be a lightweight witness, not a full copy.

  • 3 regions, 3 replicas: survives loss of any single region
  • 5 replicas as 2-2-1: survives one region loss and still has a majority with extra margin
  • 2 data regions + witness: cheaper way to get quorum

Odd replica counts avoid ties, and the right region set also depends on user geography, residency law and per-region costs.

Take quiz
What is the two-region problem?
Two regions need two TLS certs
Two regions always have lower latency
Two DNS servers disagree
With two replicas, losing either leaves no safe majority
What can the third location be in a cost-aware design?
A lightweight witness that holds no full copy
A second load balancer
A CDN edge only
A backup tape drive

44. How does Kafka replicate data across regions?

Kafka's replication within a cluster does not span regions in practice, so cross-region copying is done by a replicator such as MirrorMaker 2 (built on Kafka Connect), or by managed options like Cluster Linking.

  • MirrorMaker 2 copies topics, configs and consumer group checkpoints so consumers can translate offsets after failover
  • By default remote topics get a source-cluster prefix such as us-east.orders, which prevents replication loops
  • In active-active, each region produces to its own topic and consumers read both the local and the remote topic

Replication is asynchronous, so a failover can lose the tail of the log or reprocess messages. Consumers must therefore be idempotent.

Take quiz
Why does MirrorMaker 2 prefix remote topics with the source cluster name?
To compress messages
To prevent replication loops and keep origins distinct
To change the partition count
To encrypt payloads
Why must consumers be idempotent in cross-region Kafka failover?
Topics are always empty
Offsets are never stored
Messages may be reprocessed after offset translation
Kafka deletes consumers

45. How do you keep caches consistent across regions?

Most teams do not replicate caches between regions. Each region keeps a local cache, which is filled from the local database replica, and entries expire by TTL.

To reduce staleness, publish invalidation events from the replicated change stream (CDC) so each region invalidates its own cache once the data actually arrives locally.

  • Use versioned keys to avoid serving old values after updates
  • Pre-warm the standby cache before failover where possible
  • Expect a cold cache after failover and protect the database from the surge with request coalescing

Invalidating on write in the origin region alone is not enough, since a remote cache can reload stale data from a lagging replica.

Take quiz
Why is invalidating only in the origin region not enough?
Replication is instantaneous
Caches cannot be invalidated
TTL is disabled
A remote cache may reload stale data from a lagging replica
What protects the database from a cold cache after failover?
Request coalescing and pre-warming
Disabling health checks
Larger DNS TTL
Dropping indexes

46. How do you run schema migrations safely in a multi-region system?

During a rollout, different regions run different code versions, and replication carries changes between them. So every schema change must be compatible with both old and new code.

The standard approach is expand and contract:

  1. Expand: add the new column or table, nullable, with no code reading it yet
  2. Deploy code that writes both old and new fields, region by region
  3. Backfill existing data
  4. Switch reads to the new field
  5. Contract: remove the old field only when all regions and replicas have moved on

Never rename or drop a column in one step. Roll out one region at a time and stop if errors rise.

Take quiz
What is the first step in expand and contract?
Stop replication
Add the new schema element without removing the old
Rename the table
Drop the old column
Why must migrations be backward compatible during rollout?
Databases forbid renames
Regions share one binary
Different regions run different code versions at the same time
Replication needs downtime

47. How do you avoid a thundering herd or cascading failure during failover?

When a region fails, its traffic lands on survivors in seconds. If they were running at 70 percent, they are suddenly overloaded, and retries from clients make it worse.

  • Capacity headroom: with two regions each should run below about 50 percent, or pre-provision to absorb a full failover
  • Gradual shifting with weighted routing, for example 10, 50, 100 percent
  • Load shedding and rate limiting to protect critical paths
  • Retries with exponential backoff and jitter
  • Circuit breakers and bounded connection pools toward databases
  • Cache pre-warming to avoid a cold-cache stampede

Autoscaling alone is too slow for the first minutes, so headroom and shedding are what actually keep the system up.

Take quiz
Why is autoscaling alone insufficient at the moment of failover?
It needs manual approval
It deletes caches
Autoscaling never works in clouds
New capacity takes minutes while the surge arrives in seconds
What does jitter add to retry backoff?
Randomness so clients do not retry in sync
Faster retries
More replicas
Encryption

48. How do you safely test regional failover?

A failover plan that has never been exercised is a hope, not a plan. Test it in increasing stages.

  1. Tabletop review of the runbook with the on-call team
  2. Staging drills using fault-injection tools such as AWS Fault Injection Service, Gremlin or Chaos Mesh
  3. Planned production switchover at low traffic, with a rollback path
  4. Game days that simulate a full region loss while measuring real RTO and RPO
  5. Regular repetition, because configs and code drift

Define success criteria in advance, such as RTO under 10 minutes and RPO under 30 seconds, then record the actual numbers. Limit the blast radius by starting with a small share of traffic and having an abort button.

Take quiz
What should you compare after a failover drill?
The size of the logs only
Measured RTO and RPO against the targets
The number of engineers present
DNS vendor names
Why repeat failover tests regularly?
Cloud regions move
Replication resets itself
Configuration and code drift can silently break the process
DNS records expire daily

49. How do you monitor replication health and troubleshoot growing lag?

Monitor lag per region pair, not just on average. Useful signals are replication lag in seconds, apply queue depth, conflict rate, replication errors and per-region request error rate, plus synthetic probes from each region.

Define an SLO such as 99 percent of writes visible in every region within 5 seconds and alert on its burn rate.

When lag grows, work through this list:

  1. Check network throughput and packet loss between regions
  2. Look for large transactions or bulk jobs that stall the stream
  3. Check whether the replica's apply process is single-threaded and CPU bound
  4. Look for long-running queries on the replica blocking apply
  5. Confirm the replica is sized like the primary
  6. Throttle or reschedule write bursts

Treat rising lag as an early warning, because it is your future data loss.

Take quiz
Why alert on lag per region pair rather than on an average?
Pairs share one clock
Averages are not allowed
It lowers cost
An average can hide one badly lagging link
Which is a classic cause of sudden lag growth?
A large bulk transaction stalling the replication stream
Using multiple AZs
A new DNS record
A smaller log format

50. How can you optimize the cost of a multi-region deployment?

Multi-region cost comes from duplicated compute, duplicated storage, and inter-region data transfer, which cloud providers bill per GB and which can surprise teams with chatty replication.

  • Tier your services: active-active only for revenue-critical paths, warm standby or backup-restore for the rest
  • Scale down warm standbys and use autoscaling to expand during failover
  • Replicate only what is needed and compress replication traffic
  • Reduce cross-region calls by keeping request paths inside a region
  • Use a CDN to cut origin traffic
  • Commit baseline capacity with savings plans or reservations

Always tie spend back to RTO and RPO. If a service's downtime cost is lower than its standby cost, a cheaper tier is the right answer.

Take quiz
Which cloud charge often surprises teams in multi-region designs?
TLS certificate issuance
Inter-region data transfer
Region name changes
DNS hosted-zone creation
How do you decide which services deserve active-active?
Pick all services
Pick randomly
Compare downtime cost to the cost of running live capacity
Pick the newest services
«
»

Comments & Discussions