Sub topic 5
Active-active, active-passive, and N+1 designs
This chapter assumes you know what a load balancer is, how health checks work at a high level, and that redundancy means keeping spare copies of a component. Here you will compare the three common ways to arrange those copies.
The working model
A redundant design answers two questions. Which copies serve traffic right now? How much spare capacity is left if one copy fails?
- Active-active: every copy serves traffic at the same time.
- Active-passive: one copy serves traffic. A standby waits and takes over on failure.
- N+1: you need N copies to carry the load, and you run one extra.
N+1 describes capacity. Active-active and active-passive describe who serves traffic. They combine. For example, three active servers that each run at 60% load form an active-active pool, and two of them can still carry the full load if one fails.
Active-active
All copies handle requests, so no capacity sits idle. When one fails, the health check removes it and the others absorb its share.
The main risk is hidden overload. Suppose two servers each run at 70% load. If one fails, the survivor needs 140% of its capacity and fails too. A safe active-active pool is sized so the remaining copies can carry the full load after a failure.
State is the other difficulty. If copies hold data, writes must reach every copy or be routed carefully. Stateless web tiers fit active-active well. Databases are harder.
Active-passive
One copy is primary. The standby is kept ready, either hot (running and in sync) or cold (needs starting). Failover means promoting the standby.
This design is simpler for stateful systems because only one copy accepts writes. The costs are:
- The standby is paid for but idle.
- Failover takes time, since the system must detect the failure, decide, and switch.
- A standby that is never used may be broken without anyone noticing.
The NGINX backup keyword is a small example of this pattern. The two active servers share the traffic. The third gets requests only when both are unavailable.
upstream app {
server 10.0.0.11:8080 max_fails=3 fail_timeout=10s;
server 10.0.0.12:8080 max_fails=3 fail_timeout=10s;
server 10.0.0.13:8080 backup;
}N+1
With N+1 you compute N from peak load, then add one copy. If peak load needs 4 servers, you run 5. Losing any one copy leaves enough capacity.
The cost is only 1/N extra, so it gets cheaper as N grows. It protects against one failure at a time. If failures are likely to overlap, for example during a long repair, use N+2.
Choosing a design
| Factor | Active-active | Active-passive | N+1 |
|---|---|---|---|
| Idle capacity | None, but headroom is required | Whole standby | One spare copy |
| Failover time | Near zero | Detection plus promotion | Near zero when used with active copies |
| Complexity with state | High | Lower | Depends on the topology |
| Typical fit | Stateless web and API tiers | Primary databases, licensed software | Pools of similar servers |
Common errors
- Sizing an active-active pool so each copy runs near its limit.
- Never testing the passive copy, so it fails when needed.
- Letting the standby fall behind the primary on configuration or data.
- Counting N+1 copies that share one rack or power feed, so a single event removes several. The next chapters on fault domains and replication address this.
Exercise
Three servers form an active-active pool, and each handles 50% of its capacity. One server fails. What load does each survivor carry, and does the pool survive?
Show answer
The total load is 3 × 50% = 150% of one server. Two survivors share it, so each carries 75%. The pool survives, because 75% is below 100%.