Database Replication
DatabasesCopy your data to multiple servers to achieve fault tolerance, read scaling, and geographic distribution.
A newspaper company (Primary) prints the daily paper. It sends copies to hundreds of newsstands (Replicas) across the city. Readers can buy from any newsstand nearby - no need to travel to the print shop. If the print shop burns down, all the newsstands still have yesterday's paper.
Single-Leader (Master-Replica) Replication: One designated node accepts all writes (the leader/primary). It continuously ships write events to one or more follower nodes. Followers are read-only - they replicate and serve reads. This is PostgreSQL streaming replication, MySQL binlog replication, and Redis Sentinel.
This pattern dramatically improves read throughput: you can have 5 replicas and spread your read queries across all 6 nodes (1 primary + 5 replicas). Write throughput is unchanged because all writes still go through one node.
Synchronous vs Asynchronous replication: Synchronous means the primary waits for at least one replica to acknowledge every write before confirming success to the client. Zero data loss, but higher write latency. Asynchronous means the primary confirms immediately and replicates in the background - lower latency, but potential data loss if the primary crashes before the replica catches up.
Multi-Leader Replication: Multiple nodes accept writes. Used for multi-datacenter setups (one leader per data center). Each leader asynchronously replicates to the others. The trade-off: write conflicts can occur when the same row is modified simultaneously in two data centers.
Leaderless Replication (Dynamo-style): Used by Cassandra, Riak, DynamoDB. Any node can accept writes. The client writes to W nodes and reads from R nodes. If W + R > N (total nodes), you are guaranteed to read at least one up-to-date value. This enables extremely high availability - no single leader to fail.
- Primary goal: fault tolerance - if the primary fails, promote a replica.
- Secondary goal: read scaling - distribute reads across replicas.
- Replication lag: replicas may be seconds behind the primary (problematic for "read your own writes").
- Automatic failover (sentinel, orchestrator) needed in production.
- RPO (Recovery Point Objective) = max data loss tolerable. Sync replication = RPO of 0.
Curated Curation & Deep Insights
ScaleDojo CertifiedOur system architects are vetting high-quality, authorized video guides for Database Replication with zero third-party platform links.
We are preparing premium, zero-competitor deep-dives for Database Replication. Authorized reading references will appear automatically.