This post covers - how Couchbase achieves data partitioning and Replication.
doc = "{"key1":"value1".....}" ; doc-id = id
Steps:
- Based on key (or document id) the hash gets calculated.
- Hash returns a value in the range [0,1023] both inclusive. This is known as partition id.
- number basically maps the document to one of the vBuckets.
- Next task is to map the vBucket to a physical node. This gets decided by vBucket Map.
- This maps tells which is the primary node for the document and which all are the backup nodes. vBucket Map will have 1024 entries, one of each vBucket. And each entry also an array. The first value is for primary node and rest all are replica nodes.
- Server list stores list of live nodes. So based on the index of the vBucketMap, we get to know the physical node IP address.
No comments:
Post a Comment