Web apps & software

What is database replication?

Database replication continuously copies changes from one database server, the primary, to one or more others, called replicas, so that you have a standby if the primary fails and extra servers to answer read queries.

How it flows

Applications send writes to the primary. The primary records each change in a log, and replicas replay that log to stay current. Synchronous replication waits for a replica to confirm before accepting the write; asynchronous replication does not wait, which is faster but can lose the last few changes in a crash.

What replication is not

A replica copies mistakes instantly. If someone deletes a table, the deletion reaches every replica within moments. Replication helps availability; backups with history protect against human error. You need both.

Operating tips

  • Monitor replication lag, the time a replica trails the primary.
  • Rehearse promotion of a replica, including pointing the application at it.
  • Beware of reading your own write from a lagging replica. Setups differ by engine: PostgreSQL streaming replication, MySQL replication and managed offerings such as Amazon RDS Multi-AZ.

Questions, answered

No. It mirrors deletions and corruption too, so keep separate point-in-time backups.

A setup where several servers accept writes, which adds conflict-resolution complexity.

By the Stegnor team · Updated