https://liuzhenglaichn.gitbook.io/system-design/advanced/consistent-hashing
- hash keys on a ring
- virtual nodes (multiple hash functions for servers to make sure the servers’ virtual nodes are more evenly distributed)
- weight (weight is the number of virtual nodes of a server; powerful servers can have higher weight)
Data replication和Data sharding都要用到consistent hashing:
https://dev.to/arslan_ah/how-to-use-consistent-hashing-in-a-system-design-interview-33ge
- replication: 从key开始顺时针在环上找前N个服务器复制数据.
- 将key顺时针后的第一个server作为coordinator node, 让他负责向后复制到N-1个服务器.
- sharding: 利用consistent hashing减少增减服务器时的数据迁移量.