Database Replication
Copying the same data to multiple database nodes for redundancy and read scale, at the cost of a lag window.
Database replication keeps copies of the same data on multiple database nodes, typically one primary that accepts writes and one or more replicas that apply the same changes afterward. It solves two problems at once: redundancy (a replica can be promoted via Leader Election if the primary dies) and read scale (queries can be spread across read replicas instead of all hitting one machine — though only read scale, since every replica still has to apply every write), without changing what data exists — every replica eventually holds the same rows, unlike Database Sharding, which splits different data across nodes.
Replication is either synchronous or asynchronous, and the difference is the whole ballgame. Synchronous replication waits for a replica to confirm it has the write before telling the client the transaction succeeded, which guarantees no committed data is ever lost to a primary failure but adds the replica's round-trip latency to every write. Asynchronous replication — the far more common default — tells the client success as soon as the primary itself has durably written it, and ships the change to replicas afterward on its own schedule. That gap is replication lag: a window, usually milliseconds but sometimes much longer under load, during which a read replica can serve a value that's already stale relative to the primary.
Replication lag is the source of a specific, easy-to-miss class of bug: a user submits a form, the write commits to the primary, the very next request reads from a lagging replica, and the user's own change appears to have vanished. Systems that care about this either route a user's own reads back to the primary for a short window after their write, or accept the staleness as part of the Eventual Consistency contract and design the UI not to promise otherwise.
See also3
CAP Theorem
When a network splits a distributed system, it can stay consistent or stay available, but a proven theorem says not both.
Data & Content12 connections
Write-Ahead Logging
Recording the intent of a change durably before applying it, so a crash can be recovered.
Computation & Algorithms20 connections
Network Partition
A network failure that splits a cluster into groups that can't reach each other but keep running, and the split brain that follows when each side thinks it is in charge.
Networks & Distribution9 connections
Linked from11
- CAP TheoremData & Content
When a network splits a distributed system, it can stay consistent or stay available, but a proven theorem says not both.
- Change Data CaptureData & Content
Turning a database's own internal write log into a stream other systems can subscribe to, without touching the application.
- Chaos EngineeringTesting & Verification
Deliberately breaking parts of a running system to prove it survives failures that will eventually happen anyway.
- Consensus AlgorithmData & Content
A protocol that gets a majority of unreliable, independent nodes to agree on one value, surviving any minority failing.
- Database ShardingData & Content
Splitting one dataset across multiple databases by key, trading a single point of scale for cross-shard complexity.
- DenormalizationData & Content
Deliberately duplicating data to make reads faster, trading update complexity for query simplicity.
- Leader ElectionData & Content
The process a distributed system uses to pick one node to coordinate, and to notice and replace it when it dies.
- Network PartitionNetworks & Distribution
A network failure that splits a cluster into groups that can't reach each other but keep running, and the split brain that follows when each side thinks it is in charge.
- RAIDSystems & Tooling
Combining several disks into one logical volume for speed, redundancy, or both, through striping, mirroring, and parity, and why it is never a substitute for backups.
- Soft DeleteData & Content
Marking a record as deleted instead of removing it, which makes deletion reversible and auditable but leaks complexity into every query.
- SQLiteData & Content
A complete SQL database packaged as a small library that stores everything in one file, public domain since 2000, tested to an extreme standard, and probably the most widely deployed database in the world.