Failover and Leader Election (Patroni, Stolon)
Use Patroni or Stolon for automated failover, and configure quorum to avoid split-brain.
Why Automated Failover?
Manual failover is slow and error-prone. Tools detect primary failure and promote a replica without human intervention.
Failover Steps
What needs to happen:
- Detect primary is down (health checks, consensus)
- Pick a replica with the most recent WAL
- Promote it (pg_promote / pg_ctl promote)
- Reconfigure other replicas to follow the new primary
- Update application connection routing
All lessons in this course
- Streaming Replication and WAL
- Logical Replication for Sharding
- Failover and Leader Election (Patroni, Stolon)
- Read Replicas and Connection Routing