Stackbook Logo
resilienceestablished · medium operational burden

Active-Passive Failover

Also known as: hot-standby, primary-standby

Intent

Maintain a standby replica that takes over serving when the active primary fails.

Problem

A single instance of a stateful or singleton component is a single point of failure. Running two actives may be impossible because of write conflicts or licensing, but downtime during manual recovery is unacceptable.

Forces

  • •Recovery time objective vs standby cost
  • •Standby must have current state
  • •Split brain when both believe they are primary
  • •Failover must be tested to be trusted

Solution

Overview

In active-passive failover one node does the work while another waits. It trades idle capacity for a simple consistency story, since only one node ever accepts writes.

How it works

Replication keeps the standby current, and a detector watches the primary.

clients -> VIP -> [primary] --replicate--> [standby]
primary stops heartbeats
  1. detector confirms (quorum)
  2. fence old primary (STONITH or token)
  3. promote standby, move VIP
  4. old primary rejoins as standby

Synchronous replication avoids data loss but adds latency and can block writes if the standby is down. Asynchronous replication keeps writes fast but may lose the last few transactions. Tools such as Patroni, Pacemaker, and cloud managed databases implement this loop.

Pitfalls

  • Without fencing, a network partition produces two primaries and divergent data.
  • Automatic failback often causes a second outage, so prefer deliberate failback.
  • A standby that is never exercised may fail on first use. Run scheduled failover drills.
  • Clients with cached DNS or long-lived connections keep talking to the old primary.
  • Capacity on the standby must match the primary, otherwise promotion causes overload.

Key takeaways

  • Decide the acceptable data loss and recovery time first.
  • Always fence the old primary.
  • Use a quorum-based detector to avoid false promotion.
  • Test failover regularly and avoid automatic failback.
  • Record the measured recovery time and data loss from each drill and compare them with the stated objectives, since real numbers usually differ from design estimates.

✓ When to Use

  • •Relational databases with a single writer
  • •Singleton services such as schedulers
  • •Systems with strict write ordering needs

✗ When Not to Use

  • •Stateless services better served by active-active
  • •When replication lag loss is unacceptable and not mitigated
  • •Workloads needing full capacity from all nodes

Pros

  • +Simple consistency model with one writer
  • +Fast recovery with hot standby
  • +Clear operational mental model

Cons

  • −Standby capacity sits idle
  • −Replication lag can lose recent writes
  • −Failover logic is complex and risky

Cost Profile

Infrastructure

Medium to high, idle standby duplicates infrastructure

Operational

Medium, failover drills and monitoring

Cognitive

Medium, split-brain reasoning

Failure Modes

  • Split brain when both nodes accept writes

  • Standby is stale or misconfigured and fails to take over

  • Failover flaps between nodes during partial network failure

Real-World Examples

Alternatives

    Related Patterns

    • heartbeat
    • health-check-endpoint

    Competency Domains

    reliability opsdata state