Primary-Backup Replication

What is Database Replication?

Replication is the process of copying data from a source database server to one or more destination servers. It's a fundamental technique for achieving:

Primary-Backup (Master-Slave) Model

This is a very common replication topology. One server is designated as the Primary (or Master), and one or more servers act as Backups (or Slaves/Replicas).

Write Flow

  1. Client sends a write request to the Primary.
  2. Primary processes the write, applies it locally (e.g., to its transaction log and data files).
  3. Primary sends the update (or log record) to all connected Backup nodes.
  4. Backup nodes receive the update and apply it locally.
  5. (Confirmation back to the client depends on Sync/Async mode - see below)

Read Flow

Synchronous vs. Asynchronous Replication

Failover

If the Primary node fails:

  1. The failure needs to be detected (often via health checks or lack of heartbeats - simplified here).
  2. A Backup node needs to be chosen as the new Primary. This might involve manual intervention or an automated process (e.g., using consensus or choosing the most up-to-date replica).
  3. The chosen Backup is promoted to become the new Primary.
  4. Other remaining Backups need to be reconfigured to replicate from the *new* Primary.
  5. Clients need to be redirected to connect to the new Primary for writes.

Visualize Replication

Configure the cluster, choose replication mode, and simulate operations to see the flow.

Client


Log messages will appear here...