- Is it the “C” in the CAP ?
No offence, but I wanted to give a very simple explanation.
1. C in Replication Consistency
Here are some of reasons
- Latency — If you have users around the world, you might want to have servers worldwide, so that users can be served from a datacenter that is geographically close to them. That avoids the network delays.
Two techniques that can be used Individually or in tandem to provide the above guarantees are replication and partitioning ( or sharding)
Splitting a big database into smaller subsets called partitions, so that different partitions can be assigned to different nodes (also known as sharding).
Keeping a copy of the same data on several different nodes, potentially in different locations. Replication provides redundancy: if some nodes are unavailable, the data can still be served from the remaining nodes. Replication can also help improve performance.
These are the 3 Popular algorithms for replication: single-leader (master-slave or single-master), multi-leader (master-master or multi-master) and quorum-based replication. We are not going to get into the details of these.
So getting back to C in Replication Consistency. In a replicated data system (say single-leader variant) here are the high level rules of the game. All the write goes only to the leader and followers are read-only. All writes trickle down to the followers by a process either synchronously or asynchronously. Assume the if the catchup is asynchronous (which is default) can take some time however less it is.In normal operation, the delay between a write happening on the leader and being reflected on a follower — the replication lag — may be only a fraction of a second, and not noticeable in practice. However, if the system is operating near capacity or if there is a problem in the network, the lag can easily increase to several seconds or minutes or more. Thats why it is termed as eventual consistency. The term eventually is leaky because in general, there is no limit how far a replica can fall behind.
2. C in CAP
Here is an example
- Single-leader replication, master-slave replication and single-master replication all mean the same.
- Multi-leader replication , master-master replication and multi-master replication all mean the same.
- Leader, master, primary all mean the same
- Follower, slave, replica, secondary all mean the same
- Partitioning and sharding means the same