Active-Passive vs Active-Active for Stateful
What you'll learn: You'll understand the two primary high-availability patterns for stateful services and when to choose each approach.
The Challenge with Stateful HA
When designing high availability for stateful services—those that maintain session data, leader state, or persistent connections—you face a critical architectural choice: should only one instance serve traffic while others stand by (active-passive), or should all instances actively serve requests simultaneously (active-active)?
Active-Passive Pattern
In active-passive, one instance (the active) handles all requests while one or more standby instances remain idle, ready to take over if the active fails. The standby continuously receives state updates but doesn't serve traffic.
Think of it like: A backup quarterback on the sidelines—fully prepared, watching every play, ready to jump in, but not actively playing unless the starter goes down.
Benefits: Simpler consistency guarantees, easier to reason about, no split-brain risk.
Drawbacks: Wasted standby capacity, slower failover transition, potential data loss during switchover.
Active-Active Pattern
In active-active, multiple instances serve traffic simultaneously, sharing or replicating state in real-time. All instances are productive participants.
Think of it like: Multiple cashiers at a store, all checking the same inventory system—everyone works, but coordination is crucial.
Benefits: Full resource utilization, instant failover (no promotion needed), better performance.
Drawbacks: Complex state synchronization, potential consistency conflicts, requires distributed consensus mechanisms.
Choosing Your Pattern
Active-passive works well for databases, stateful sets with leader election, and services where sequential consistency is paramount. Active-active suits distributed caches, eventually-consistent datastores, and workloads that can handle conflict resolution.
Key Takeaway: Active-passive sacrifices resource efficiency for simpler consistency; active-active maximizes utilization but demands sophisticated state coordination and conflict resolution mechanisms.