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
Database Sharding
Splitting one dataset across multiple databases by key, trading a single point of scale for cross-shard complexity.
Data & Content6 connections
Eventual Consistency
A guarantee that replicas converge given no further updates, without guaranteeing when.
Networks & Distribution16 connections
CAP Theorem
When a network splits a distributed system, it can stay consistent or stay available, but a proven theorem says not both.
Data & Content9 connections
Related1
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from6
- 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.
- 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.