Replica Promotion and Failover Basics
What you'll learn: How a replica database automatically takes over when the primary database fails, keeping your system running.
The Problem
You've set up a primary database and several read replicas. Traffic flows smoothly—until suddenly, your primary database crashes. Without a failover mechanism, all write operations stop. Your application can't create new users, process orders, or save any data. This is a disaster.
What is Replica Promotion?
Replica promotion is the process of elevating one of your read replicas to become the new primary database when the original primary fails. Think of it like a vice president automatically becoming president when the president is incapacitated—the role transfers, and operations continue.
How Failover Works
When the primary fails:
- Detection: Monitoring systems or consensus mechanisms detect the primary is unresponsive
- Selection: A healthy replica is chosen (usually the one with the most up-to-date data)
- Promotion: The selected replica is reconfigured to accept writes
- Redirection: Your application is pointed to the new primary
- Catch-up: Other replicas begin replicating from the newly promoted primary
The Handoff Analogy
Imagine a relay race where the lead runner (primary) suddenly falls. The second runner (replica) must grab the baton and become the new leader. The other runners adjust their course to follow the new leader. The race continues with minimal disruption.
Manual vs Automatic Failover
Failover can be manual (a human promotes a replica) or automatic (software detects failure and promotes automatically). Automatic failover is faster but requires careful configuration to avoid promoting the wrong replica or causing split-brain scenarios.
Key Takeaway: Replica promotion allows a read replica to become the new primary database during failures, ensuring your system remains available for writes with minimal downtime.