Data Replication

The process of storing identical copies of data across multiple servers or nodes to improve availability, fault tolerance, and read performance.

Common topologies include Primary-Secondary (master-slave, where only one node accepts writes) and Active-Active (multi-master, where any node can accept writes, requiring complex conflict resolution like CRDTs).

        graph LR
  Center["Data Replication"]:::main
  Rel_data_recovery["data-recovery"]:::related -.-> Center
  click Rel_data_recovery "/terms/data-recovery"
  Rel_data_obfuscation["data-obfuscation"]:::related -.-> Center
  click Rel_data_obfuscation "/terms/data-obfuscation"
  Rel_data_integrity["data-integrity"]:::related -.-> Center
  click Rel_data_integrity "/terms/data-integrity"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 5

🧒 Explain Like I'm 5

Imagine you have a top-secret recipe, and you only keep it in one notebook. If your dog eats the notebook, the recipe is gone forever. Data replication is like giving a photocopy of the recipe to five of your friends who live in different cities. If your notebook is destroyed, your friends still have it. If you change a measurement in the recipe, you have to call all your friends to update their copies so everyone has the exact same version.

🤓 Expert Deep Dive

CAP Theorem Implications
Replication forces a trade-off defined by the CAP Theorem: in the event of a network Partition (P), a system must choose between Consistency (C) and Availability (A).

Replication Strategies
1. Synchronous: The primary node waits for confirmation from all replicas before confirming the write to the client. Guarantees strong consistency (no data loss) but suffers from high latency and reduced availability (if one replica is down, writes fail).
2. Asynchronous: The primary node confirms the write immediately and updates replicas in the background. Highly available and low latency, but risks data loss if the primary crashes before replicas sync (eventual consistency).
3. Consensus-based: Uses protocols like Paxos or Raft to require a 'quorum' (majority) of nodes to acknowledge a write. This balances latency and fault tolerance.

Blockchain Replication
Blockchains use multi-master, peer-to-peer asynchronous replication. Nodes sync via gossip protocols. Consistency is achieved probabilistically via consensus mechanisms (e.g., Proof of Work), resolving conflicting states by selecting the 'longest chain'.

❓ Frequently Asked Questions

Why do databases use data replication?

To prevent data loss if a server crashes (fault tolerance), and to allow more people to read the data simultaneously without overloading a single server.

What is the difference between synchronous and asynchronous replication?

Synchronous replication makes sure every copy is updated before finishing a task (slower but safer). Asynchronous replication finishes the task immediately and updates the copies in the background (faster, but risks data loss if it crashes before syncing).

Is a blockchain a replicated database?

Yes. A blockchain is a decentralized, peer-to-peer replicated database. Every full node on the network holds a complete, identical copy of the entire transaction history.

📚 Sources