Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

Replication

Stephen M. Reaves

::

2023-02-11

Notes about Lesson 6 of CS-7210

Required Readings

Optional

Summary

Goal of Replication

State available on more that one node

Different nodes can provide the same service

Benefits

Replication Models

Active

Each replica is active

Each replica can:

Standby (Primary/Backup)

Only one replica is active/primary at one time

Updates are kept consistent so failover can be fast

Replication Techniques

State Replication

Execute updates on one replica, copy state changes to update other replicas

Good when execution is expensive

State may be large and/or hard to identify where all the updates are

Replicated State Machine

Copy each (log of) operation to each replica and execute to produce same state update

Only works on deterministic operations

Sending operation logs can be faster than sending large state

Re-execution might be expensive

Replication and Consensus

Ensure consensus for updates to replicas

Ordering and visibility of updates:

Chain Replication

Normally, cost of consensus is proportional to number of nodes

Write -> R1 -> R2 -> R3 -> Ack

Read -> R3 -> Ack

Pros:

Cons:

CRAQ

Problem with Chain Replication: Reads limited to tail replica only

Enter Chain Replication with Apportioned Queries (CRAQ)

apportioned := divided among the chain

queries := read operations

writes continue to be handle by head replica

Reads are divided among all the replicas

Each node maintains new and old values, serves old value until new value is fully replicated down the chain

CRAQ vs CR Scalability

Testing read throughput

Experiment:

Observations: