Replication

High numbers of read only operations

Why Replicate?

Challenges of replication

Leaders and Followers

Each write must be processed by every replica, otherwise nodes will not hold same data. Reads can be performed on both leaders and followers.

  1. Get consistent snapshot (read: back-up snapshot) of leader’s database (already saved somewhere)
  2. Copy snapshot to follower
  3. Since leader likely has update in this time, get the leader’s replication log
  4. Apply log. Once processed, follower should be caught-up

Synchronous vs Asynchronous Replication

Outage Handling

Follower Failure: Catch Up Recovery Leader Failure: Failover

Replication Logs

Eventual Consistency

Avoidance:

Multi Leader Replication

Multiple leaders, who each have a master replica. They perform conflict resolution to apply changes.

The problem is write conflicts can occur. These can be handled by…

Leaderless Replication

Read and Write Quorums (Quorum Consistency)

n = Number of Nodes
w = Confirmations for Write
r = Confirmations for Read

Assuming quorum conditions, we can tolerate some failures…

Essentially we send reads/writes to all nodes in parallel. w and r determine, how many nodes we wait to respond, before we can consider it successful and get an “acceptable” result

Limitations:

Sloppy Quorum & Hinted Handoff


Additional Info

Catch Up Recovery

Failover

synchronous or asynchronous

  • Single-leader replication
  • Multi-leader replication
  • Leaderless replication