Core concepts
Replication
Copies of data for failover and for read scale: sync versus async, lag, and what 'the primary died' actually looks like.
Replication copies a log of changes from a primary to one or more standbys. You do it for two different reasons, and the configuration is not the same.
Read scale
Send reads that tolerate staleness to replicas. Listing a restaurant’s menu, a public profile, a search result: fine. Send the read that follows a user’s own write to the primary, or pin that session to the primary for a second. Replica lag of hundreds of milliseconds is normal. Lag of minutes is an incident, and you only know if you graph it.
Replicas do not make writes faster. Every write still hits the primary’s log.
Failover
A replica can be promoted when the primary is dead. The dangerous moment is split brain: two nodes both accept writes. Fencing (the old primary cannot write once it is demoted; a token or a STONITH step) matters more than the election algorithm. Say who forms a quorum. A primary plus one replica cannot elect anyone if they cannot talk; you wanted three nodes, or an external witness.
Asynchronous replication means the acknowledged write might not be on any replica yet. A crash can lose those commits. Synchronous replication (or a quorum write) shrinks that window and adds latency. For money, lean synchronous or quorum. For a feed, asynchronous is usually the right call, and you say the loss window out loud.
Quorum form
Dynamo-style systems skip a single primary. A write succeeds when W replicas accept it. A read succeeds when R respond. If R + W > N, a read sees the latest write in the absence of other failures. If not, you have a conflict-resolution story (last-writer-wins, vector clocks, or an application merge). Do not claim quorum and also claim you never resolve conflicts.
What replication is not
It is not a backup. An operator’s DELETE without a WHERE will be dutifully copied. Backups are snapshots plus a log you can restore to a timestamp, stored somewhere a bug cannot reach, and you have restored them once. Mention both if the data matters.
flowchart LR
App[Writers] --> P[(Primary)]
P -->|async log| R1[(Replica)]
P -->|async log| R2[(Replica)]
Readers --> R1
Readers --> R2
App -->|read-your-writes| P Further reading
Check yourself
Answer the questions. Multiple choice is scored on this device only.
1. Async replicas primarily buy you what?
2. A user posts and immediately refreshes, and the post is missing. What is the likely cause?
3. What does synchronous replication cost?