Sub topic 1
What Active-Active Means and How It Differs from Active-Passive
Prerequisites
This chapter assumes you know the following:
- Basic cloud networking and DNS: what a region is, how a DNS record resolves to an IP address, and what a TTL (time to live) does.
- Stateless web services behind a load balancer.
- How a relational or NoSQL database stores and replicates data at a basic level.
- Availability and latency as service goals, for example "99.9% of requests succeed" or "p95 latency under 200 ms".
You do not need prior multi-region experience. Later chapters cover routing, replication, and conflicts in detail. This chapter gives you the working model they build on.
The core idea
A multi-region design runs your service in more than one geographic region, such as us-east-1 and eu-west-1. The designs differ in how they use those regions.
In an active-active design, every region serves live production traffic at the same time. Each region can accept reads and writes from users. If one region fails, the others already carry traffic and absorb its share.
In an active-passive design, one region (the primary) serves all traffic. A second region (the standby) receives replicated data and sits ready. When the primary fails, you promote the standby and redirect traffic to it.
The word "active" describes the role of a region's compute and traffic. It does not tell you how the data layer behaves. A design can serve traffic from every region and still send all database writes to one region. Whether writes are accepted in every region is the hardest part of active-active, and it is the focus of later chapters.
Comparing the two models
| Dimension | Active-passive | Active-active |
|---|---|---|
| Traffic | One region serves all users | Every region serves users |
| Failover | Detect, promote, redirect | Remove the failed region from routing |
| Typical recovery time | Minutes to hours, depending on automation | Seconds to a few minutes, bounded by health checks and DNS |
| Data loss on failure | Possible, equal to replication lag | Possible for writes not yet replicated |
| User latency | Good near the primary, worse far away | Good everywhere, since users reach a nearby region |
| Idle capacity | Standby is mostly unused | All capacity serves traffic, but you need headroom |
| Data conflicts | Not possible with a single writer | Possible when regions accept writes to the same data |
| Complexity | Moderate | High |
| Cost | Lower to moderate | Higher |
Two rows deserve more attention.
First, failover. In active-passive, failover is an event. Someone or something must decide the primary is gone, promote the standby database, and redirect traffic. Each step can fail, and the standby may never have been tested under real load. In active-active, a region failure is closer to a routing change, because the surviving regions already serve traffic and already run the code path.
Second, conflicts. A single writer cannot conflict with itself. Once two regions accept writes to the same record, you must decide what happens when both change it before they have heard about each other's change.
What "active-active" can mean in practice
The term covers several designs. Be clear about which one you mean, because they have very different costs.
- Active-active compute, single-writer data. Every region runs the application, but one region owns the database for writes. Other regions serve reads from local replicas and forward writes to the owner. This is the simplest form. Write latency suffers for users far from the owner, and a failure of the owning region still needs a database failover.
- Active-active with partitioned writes. Each piece of data has a home region. For example, European customers are written in
eu-west-1, and US customers inus-east-1. Every region accepts writes, but only for its own partition, so conflicts do not occur. A user who travels still reaches the home region, at the price of extra latency. - Active-active with multi-writer data. Any region can write any record. Replication runs in both directions, and the system must resolve conflicts. This gives the best write latency and availability, and it needs the most care in application design.
Many production systems mix these. A user profile might use partitioned writes, a shopping cart might use a conflict-free data type, and a payment ledger might stay single-writer.
Why teams choose active-active
Three goals usually drive the decision.
- Availability beyond one region. A single region has a finite availability. If your target is higher than what a region can deliver, or the business cannot tolerate a regional outage, you need a second region that is already working.
- Lower latency for global users. Light in fiber takes roughly 70 ms to cross the Atlantic one way in practice, so a user in Frankfurt calling a server in Virginia pays that cost on every round trip. Serving from a nearby region removes it.
- Faster, more reliable recovery. A failover path that runs every day is exercised constantly. A standby that sits idle for a year often fails when first used, because of configuration drift, expired credentials, or missing capacity.
Active-active does not give you these for free. It trades simplicity and cost for them.
A small example of the conflict problem
Suppose a record holds a user's favorite color. At nearly the same moment, a user's phone writes blue in eu-west-1 and a laptop writes green in us-east-1. Each region accepts its write locally and replicates it. When the changes cross, each region sees a competing value.
The simplest policy is last-writer-wins, where the version with the higher timestamp wins. This code makes the choice deterministic by using the region name as a tie-breaker, so every region picks the same winner regardless of the order in which it sees the versions.
def lww_merge(a, b):
"""Each version is a (timestamp, region, value) tuple.
The higher timestamp wins; the region name breaks ties
so every region picks the same winner."""
return a if (a[0], a[1]) >= (b[0], b[1]) else b
from_eu = (1700000005.2, "eu-west-1", "blue")
from_us = (1700000005.2, "us-east-1", "green")
print(lww_merge(from_eu, from_us)) # (1700000005.2, 'us-east-1', 'green')
print(lww_merge(from_us, from_eu)) # same result in either orderBoth regions converge to green. The cost is that blue is silently discarded, and the result depends on clocks that can drift between regions. For a favorite color this is acceptable. For an account balance it is not. Chapter 9 covers better options, including version tracking and CRDTs (conflict-free replicated data types).
Common mistakes
- Treating "two regions" as "active-active". If a second region exists but receives no traffic, it is active-passive, however many servers run there.
- Ignoring the data layer. Stateless compute is easy to run in many places. Most of the difficulty sits in the database and in any state held by queues, caches, and sessions.
- No headroom. If two regions each run at 70% load, one region cannot absorb the other's traffic. After a failure, the survivor is overloaded and the outage spreads. Capacity planning is covered in a later chapter.
- Assuming failover is automatic and correct. Health checks can pass while the region is unusable, or fail while it is healthy. Both cause bad routing decisions.
- Applying active-active to everything. Some data sets are better kept single-writer. Choose per data set, not per system.
Choosing between the models
Use these questions as a first filter.
- Can the business accept minutes to hours of downtime during a regional outage? If yes, active-passive, or even backup and restore, may be enough.
- Do users in distant regions need low write latency? If yes, active-active with partitioned or multi-writer data is worth considering.
- Can the data model tolerate conflicts, or be partitioned so they cannot happen? If neither, stay with a single writer.
- Does the team have the operational skill to test failure regularly? If not, the extra regions may add risk instead of removing it.
Summary
Active-active means every region serves live traffic. Active-passive keeps a standby idle until a failure. Active-active improves latency and shortens recovery, and it adds conflicts, replication lag, and higher cost. The data layer decides how hard the design is: single-writer, partitioned, and multi-writer designs sit along a scale from simple to demanding. The rest of this tutorial follows that scale.
Exercise
A team runs its application in us-east-1 and eu-west-1, and both regions serve users. All database writes go to a single primary in us-east-1, and eu-west-1 has a read replica. Is this active-active or active-passive? Name one failure case where it still behaves like active-passive.
Show answer
It is active-active at the compute and read level, because both regions serve live traffic, with a single-writer data layer. If us-east-1 fails, no region can accept writes until the team promotes the eu-west-1 replica to primary. That step is a manual or automated database failover, the same as in active-passive, and any writes not yet replicated are lost.
Exercise
Two regions both accept writes to a user's display name. Region A records "Sam" at timestamp 100.0 and Region B records "Samuel" at timestamp 100.0. With the lww_merge function above, which value wins if Region A's region name is eu-west-1 and Region B's is us-east-1? What is lost?
Show answer
"Samuel" wins, because the timestamps tie and the tuple comparison falls to the region name, and us-east-1 sorts after eu-west-1. The value "Sam" is silently dropped. Every region reaches the same answer in either order, but one user's write is discarded without notice.