Replication
Replication is the process of automatically copying and synchronising data across multiple servers so the same information exists in more than one place. It is most often discussed in the context of databases, but files, objects in a storage system and entire file systems can be replicated too. The goals are higher availability, load distribution, and keeping data geographically closer to users in different regions.
How replication works
A source server (the master or primary) records every change in a transaction log, and target servers (slaves or replicas) read that log and replay the same operations on themselves. This keeps replicas a faithful mirror of the source. There are two main modes:
- asynchronous replication — the source acknowledges a write immediately and replicas catch up with a slight lag; fast, but risks losing the most recent transactions in a sudden failure,
- synchronous replication — a write is confirmed only after it is durable on the replicas; safer, but slower.
In terms of topology you will meet the master-slave model (one writer, many readers) and master-master, where several nodes accept writes at the cost of complex conflict handling.
Replication in practice
Replication underpins high-availability architectures: if the primary node fails, traffic switches to a replica (failover) and the service keeps running. It also scales reads — SELECT queries are spread across replicas to offload the writer, a pattern used by high-traffic stores and portals. Engines such as MariaDB and MySQL provide replication natively. Remember that a replica is not a backup — it faithfully copies bad operations as well, so full protection comes only from combining replication with regular backups.
Powiązane pojęcia
Najczęstsze pytania
How is replication different from a backup?
Replication keeps a live, current copy of data on another server for availability and read scaling. A backup is a point-in-time snapshot that protects against mistakes or deletion. Because replication instantly copies errors too, it is not a substitute for backups.
Does synchronous replication slow down the database?
It can, because a write is only acknowledged once it has been stored on every node, adding network latency. In return it guarantees that no committed transaction is lost after a failure, which is critical for financial and other high-integrity systems.
