Copies of the Truth
Module 3 treated the database as one node. Real systems keep more than one copy of the same data, for two reasons: so a single node's failure does not lose the data, and so reads can be spread across more than one machine. Replication is how those copies are kept in sync, and the sync strategy you choose decides exactly how fresh a "second opinion" is allowed to be.
Primary-Replica Topology
The most common replication shape has one primary node that accepts all writes, and one or more replicas that receive a copy of every change and serve read traffic. Spreading reads across replicas is a direct scaling win, exactly the horizontal scaling idea from Module 2, applied to the database tier instead of the application tier. Writes still have to go through the primary, which is why replication alone does not solve write scalability, only read scalability; sharding, the next lesson, is what addresses writes.
Synchronous vs Asynchronous
| Synchronous replication | Asynchronous replication | |
|---|---|---|
| When the client is told the write succeeded | After at least one replica confirms it received the write | Immediately, before any replica has it |
| Guarantee | A replica is never behind by even one committed write | None: if the primary fails before copying, that write can be lost even though the client was told it succeeded |
| Cost | Extra latency on every write; blocked if that replica is slow or unreachable | None: writes are faster and do not depend on a replica's availability |
Why the Choice Matters Beyond Just Speed
This is not only a performance knob. If your replicas also serve reads, asynchronous replication means a read immediately after a write can return stale data, the exact problem the next few lessons (eventual consistency, CAP theorem) spend real time on. And if you promote a replica to replace a failed primary, asynchronous replication means that promotion can lose the last few writes the old primary had accepted but not yet replicated. Choosing sync vs async replication is choosing, concretely, how much very recent data you are willing to risk losing in exchange for lower write latency.