Skip to content
IT glossary
DatabasesUpdated December 3, 2026

Replication

Репликация

Database replication keeps copies of the same data on multiple nodes and passes changes between them. The copies can serve read traffic or help the database recover when a node fails.

What replication gives you

A database can keep the same records on more than one machine. Instead of manually copying those records every time something changes, replication sends updates to the other copies, called replicas. This gives the application more places to send reads and a way to resume service if the main database fails. It does not mean every copy is up to date at every instant.

Where writes go

In a single-leader setup, the application sends writes to the primary. The primary records the changes and streams them to replicas, which apply them locally. PostgreSQL physical streaming replication, for instance, ships records from the write-ahead log (WAL). Some databases accept writes on multiple nodes instead; their replication design has to account for concurrent updates to the same data.

The key question is when the database tells the client that a write succeeded. With asynchronous replication, the primary can acknowledge a commit before any replica confirms it. That keeps replica delays off the commit path, but a replica may serve stale data. If it takes over while behind, some acknowledged writes may be missing. With synchronous replication, the primary waits for the configured replica acknowledgments. Waiting adds latency and can hold up commits if the required replicas are unreachable. Check what an acknowledgment means: receiving a change, making it durable, and applying it so queries can see it are distinct steps.

Example: an order that seems to disappear

A checkout service creates an order on the primary and returns its ID. The confirmation page looks up that ID on a read replica. If the replica hasn't applied the insert yet, the page reports that the order doesn't exist, even though the write succeeded. One fix is to send the confirmation read to the primary. A more selective approach is to use a replica only after it has applied changes through the relevant log position. Less time-sensitive reads, such as browsing the product catalog, can still go to replicas.

What replicas don't solve

Adding read replicas can increase read capacity, but it won't normally increase write capacity when all writes still go through one primary. That's a different problem from sharding: sharding splits a dataset into subsets, while replication copies data. A deployment can do both by giving each shard its own replicas.

Replicas also aren't backups. An accidental deletion can propagate to the copies, so you still need a way to restore an earlier state. And a spare copy isn't automatic failover: the system must choose a replacement, redirect traffic, and make sure the old primary can't keep accepting writes alongside the new one.

How it comes up in interviews

Expect a scenario rather than a request for a definition: a read-heavy service needs to survive a database failure, but some pages must show the user's latest write. Start by identifying which reads can tolerate stale data and how much acknowledged data the service can afford to lose. Then explain how those requirements shape read routing, commit acknowledgments, and failover.