Sub topic 5
Active-active, active-passive, and N+1 designs
This chapter assumes you know how availability is calculated for components in series and in parallel. It also assumes you know what a single point of failure is, and you should be comfortable with load balancers and health checks at a high level. Here you will compare the three common ways to arrange redundant copies of a component. You will also see which failure modes each one handles well, and which it hides.
Three ways to arrange spare capacity
Redundancy only helps if the spare copies can take over. The topology you choose decides how much capacity you pay for, how fast traffic moves after a failure, and what can go wrong during the move.
- Active-active: every copy serves traffic all the time. A load balancer or client spreads requests across them.
- Active-passive: one copy (the active, or primary) serves traffic. Another copy (the passive, standby, or secondary) waits and takes over if the primary fails.
- N+1: you need N units of capacity to carry the load, and you run N+1 units. Any single unit can fail and the remaining N still carry everything.
These are not exclusive. A common production design is an N+1 pool of active-active web servers in front of an active-passive database.
Active-active
In an active-active design, all copies handle live requests. If one fails, the load balancer stops sending it traffic and the survivors absorb its share.
Strengths:
- No idle hardware. Every unit earns its cost during normal operation.
- Failover is mostly a routing change. The survivors are already warm: caches are filled, connections are open, and code paths are exercised.
- Continuous proof. Because every copy serves real traffic, a broken copy shows up quickly.
Weaknesses:
- Capacity trap. If two servers each run at 70% load, losing one asks the survivor to carry 140%. Active-active gives you availability only if the remaining copies have headroom. Without headroom, a failure becomes an overload, and the overload can take down the survivors too.
- State must be shared or partitioned. Requests can land on any copy. Sessions, locks, and writes therefore need a shared store, sticky routing, or a data layer that accepts concurrent writes. Multi-writer databases need conflict handling, which is hard.
- Harder to reason about. Two copies can disagree for a short time, and you must decide whether that is acceptable.
Active-active suits stateless or read-mostly tiers such as web servers, API workers, and caches, where any copy can answer any request.
Active-passive
In an active-passive design, only the primary serves traffic. The standby receives replicated data, and sometimes also receives a stream of health signals from the primary. When the failure detector decides the primary is gone, the standby is promoted.
Strengths:
- Simple data model. One writer means no write conflicts. This is why most relational databases use a single primary with replicas.
- Predictable load. The standby is sized like the primary, so failover does not change the capacity picture.
Weaknesses:
- Paying for idle capacity. The standby does no useful work for customers until a failure happens.
- Slower failover. The system must detect failure, decide, promote, and redirect traffic. This is the sequence covered in a later chapter. Recovery takes seconds to minutes, not milliseconds.
- Untested standby risk. A standby that has never served traffic may have stale configuration, missing credentials, a different software version, or too little capacity. You find out at the worst moment.
- Split-brain risk. If the standby wrongly decides the primary is dead, both may accept writes. Quorum and fencing, covered later, address this.
Warm, hot, and cold standbys
"Passive" covers a range of readiness.
| Standby type | State | Typical takeover time | Cost |
|---|---|---|---|
| Hot | Running, data continuously replicated, ready to serve | Seconds | Highest |
| Warm | Running at reduced size or with delayed data, needs scaling or catch-up | Minutes | Medium |
| Cold | Defined in code or image form, started only on failure | Tens of minutes or more | Lowest |
Choose the standby type from your recovery time objective, which is the subject of a later chapter. A cold standby cannot meet a 30-second target no matter how well it is scripted.
N+1 and its relatives
N+1 sits between the other two. You work out how many units carry peak load (N), then add one spare. The spare is usually just another member of an active pool, so N+1 is typically an active-active pool with deliberate headroom.
For example, suppose peak traffic needs 4 servers. With N+1, you run 5. In normal operation each carries 80% of what it would at N=4. If one fails, the other four each carry 100% of their sized capacity.
The cost of redundancy falls as N grows. Protecting one server with a full duplicate (1+1) costs 100% extra. Protecting a pool of ten with one spare costs 10% extra. Bigger pools are cheaper to protect, but with more units there is a higher chance that two fail in the same period.
Related patterns:
- N+2: two spares. Use it when repairs are slow or when maintenance and failure can overlap. Taking one node out for a rolling upgrade while another fails is a common reason.
- 2N: a full duplicate of the whole system. This is the most expensive and the most resilient, and it is common for power and network feeds.
- N+M across zones: spares are placed in different fault domains so that losing one domain still leaves N units.
The last point matters. Five servers in one rack are an N+1 pool, but a single rack power failure removes all of them. Spares count only if they sit outside the failed component's fault domain.
Sizing headroom
To survive the loss of one unit in a pool of n equal units, each unit can run at no more than (n - 1) / n of its capacity during normal operation. The following script computes that limit and checks a given load.
def max_safe_utilization(units, failures_tolerated=1):
if failures_tolerated >= units:
raise ValueError("cannot tolerate losing every unit")
return (units - failures_tolerated) / units
def survives(units, utilization, failures_tolerated=1):
return utilization <= max_safe_utilization(units, failures_tolerated)
for n in (2, 3, 5, 10):
print(n, round(max_safe_utilization(n), 2))
print(survives(2, 0.70)) # False: survivor would run at 140%
print(survives(5, 0.70)) # True: survivors run at 87.5%The output shows that a pair must stay at or below 50% load to survive a failure, while ten units can run at 90%. This is the main reason that large active-active pools are efficient.
Availability math for each topology
Using the series and parallel formulas from earlier chapters, two independent 99% components in parallel give about 99.99%. This applies to both active-active and active-passive, but only under conditions that differ.
- For active-active, the parallel formula holds if the survivors can carry the full load. Otherwise the pair behaves like a series system under overload.
- For active-passive, failover itself takes time and can fail. The effective availability is lower than the parallel formula suggests. You can model this as the probability that failover succeeds multiplied into the result. If failover works 95% of the time, the improvement is much smaller than the theory predicts.
The formula also assumes independent failures. Shared software, shared configuration, and shared dependencies make copies fail together, and redundancy cannot fix that.
Choosing between them
Use these criteria in order.
- Is the component stateless? If yes, prefer active-active or N+1. It is cheap and fast.
- Does it have one authoritative writer? If yes, such as a classic relational database, prefer active-passive with replication.
- What recovery time is required? Seconds suggests active-active or a hot standby. Minutes allows a warm standby.
- What does idle capacity cost? For small components a full standby is cheap. For large ones, N+1 across a pool is cheaper.
- Can the team test it regularly? A design you cannot exercise will degrade. Active-active gets exercised for free. Active-passive needs scheduled drills.
| Concern | Active-active | Active-passive | N+1 |
|---|---|---|---|
| Resource use | High | Low (idle standby) | High, with one spare |
| Failover speed | Fastest | Slower | Fast |
| Write conflicts | Possible | None | Depends on layer |
| Capacity risk | Overload after loss | Standby undersized | Spare too small for two failures |
| Best fit | Stateless services | Single-writer databases | Server pools |
Common mistakes
- Counting a spare that shares a fault domain. Two servers on one host are not redundant against host failure.
- Running active-active at high utilization. The pool looks healthy until the first failure.
- Never promoting the standby. Configuration drift accumulates unseen.
- Mixing up redundancy and backup. A replica copies mistakes, such as a bad delete, almost immediately. Backups protect against that, and redundancy does not.
- Assuming two active sites mean two writers. Many "active-active" databases still route all writes to one node.
Exercise
A service needs 6 servers to carry peak load. You run 8 servers behind a load balancer, all active, and each runs at 75% of its capacity at peak. Does the pool survive the loss of one server? Does it survive the loss of two? Explain your answer using the headroom formula.
Show answer
The total load is 8 × 0.75 = 6 server-equivalents. With one server lost, 7 remain, so each runs at 6/7, about 86%, which is below 100%, so the pool survives. The formula agrees: the maximum safe utilization for 8 units tolerating 1 failure is 7/8 = 87.5%, and 75% is below that. With two servers lost, 6 remain, so each runs at 6/6 = 100%. That is exactly at capacity and leaves no room for retries or cold caches, so it technically survives but is not safe. The formula limit for 2 failures is 6/8 = 75%, so the pool is right on the edge. In practice this is N+2 with no margin.
Exercise
A team runs a relational database with a primary and a standby that has never been promoted. They call it highly available. Name two risks of this setup and one practice that reduces them.
Show answer
Risk 1: the standby may have configuration drift, such as missing credentials, a different version, or too little capacity, so promotion may fail or perform badly. Risk 2: failover has never been timed, so the real recovery time is unknown and may miss the target. A practice that reduces both is a scheduled failover drill, where the standby is promoted on purpose and then restored, with the observed time recorded.