Database High Availability: Surviving Server Failure
High Availability (HA) means having a hot standby database ready to take over instantly upon failure. It's essential for critical systems like payment gateways where downtime is unacceptable.
Why it exists
A single database server is a critical point of failure for most applications. If that server crashes due to hardware or software issues, the entire service becomes unavailable until an administrator manually intervenes. High Availability was created to eliminate this downtime by automating recovery.
The mental model
Think of a lead pilot and a co-pilot in an airplane cockpit. Both are fully capable of flying the plane. If the lead pilot becomes incapacitated, the co-pilot immediately takes control without passengers even noticing. In a database HA cluster, one server is the "active" pilot, and one or more "standby" servers are the co-pilots, ready to take over instantly.
How it works
HA systems use specialized software to constantly monitor the health of the primary database server, often via a "heartbeat" signal. If this signal is lost, the software assumes the primary has failed and triggers a failover process. First, it ensures the old primary is truly offline to prevent a "split-brain" where two servers think they are in charge. Second, it promotes a standby node to become the new primary. This involves reconfiguring network routes and potentially mounting storage so that application traffic is seamlessly redirected to the new, healthy server.
When to use it
Implement HA for mission-critical databases where uptime is paramount and downtime is measured in lost revenue or user trust. This applies to online transaction processing (OLTP) systems, e-commerce platforms, financial services, and any application with a strict Service Level Agreement (SLA) promising 99.99% uptime or higher.
When not to use it
HA adds significant operational complexity and infrastructure cost. It's often unnecessary for development environments, internal analytics platforms, or non-critical applications where a manual recovery process taking minutes or hours is acceptable. If your Recovery Time Objective (RTO) is flexible, a simpler backup-and-restore strategy may be sufficient.
One canonical example
A classic active-passive PostgreSQL cluster. The active node handles all reads and writes. A second, passive standby server receives all data changes from the primary via streaming replication. Monitoring software like Patroni detects if the active node goes down. It then automatically promotes the standby to become the new active node and reconfigures the application's connection endpoint, typically completing the failover in under 30 seconds.
Interview question
Which scenario most strongly indicates the need for a database High Availability solution?
- a.A database for a new prototype application where rapid iteration is prioritized over immediate stability.
- b.A data analytics database where data consistency is paramount, but queries can tolerate delays if the primary fails.
- c.A database supporting an internal tool where occasional downtime for maintenance is acceptable.
- d.A database for an online payment gateway that processes millions of transactions daily and has a strict uptime SLA.Correct
Why? this is the answer
The card states HA is for "mission-critical databases where uptime is paramount" and specifically mentions "online transaction processing (OLTP) systems, e-commerce platforms, financial services." An online payment gateway perfectly fits this description, requiring continuous operation and minimal downtime, unlike scenarios where some downtime or delays are acceptable.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #databases
- #architecture
- #reliability
- #failover
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on databases — each one lists the topics its interview covers.
See open roles