Purpose of replication
Approaches of replication
Consistency models to deal with replication lag.
Approaches of replication - Single-leader replication
Compare sync and async replication
Sync:
Pros: Followers guarantee to have up-to-date copy of data
Cons: Follower might block the write
Async:
Pros: Non blocking. Fast
Cons: Data lost if lead fails
In practical, one lead, one sync follower, all others are async. (The only one sync follower is to handle the failure of the lead)
Consistency models to deal with replication lag - 1. Reading your own writes
Additional complexity when handling cross-device
Consistency models to deal with replication lag - 2. Monotonic reads
Problem: Users see things moving backward in time due to async followers.
Implementation: Make sure each user always makes reads from same replica. e.g. - user id based hashing.
Consistency models to deal with replication lag - 3. Consistent prefix reads
Problem: A third person observed the conversation in wrong order.
Solve: Make sure any writes that are causally related to each other are written to the same partition.
Implementation of replication logs
Approaches of replication - Multi-leader replication
Use case
Approaches of replication - Multi-leader replication
Handling write conflicts
Approaches of replication - Multi-leader replication
Topologies
Approaches of replication - Leader-less replication
w + r > n, w and r determines how many nodes we wait for.