一致性哈希 Consistent Hashing
一致性哈希主要是用来解决哈希不均的问题
Where does each key live/partition in the Shard Store System?
- Keys are partitioned/sharded
- how to assign keys
- Goals:
- balance load, even as servers join and leave
- minimize key movement/redistirbuted work when configuration changes
- No centralization (remove the shardmaster)
- Proposal1: Hashing
- For n nodes, a key K goes to hash(K) mod n
- Description:
- balance load: satisfied by the randomness of hash functions
- TODO: hash
- balance load: satisfied by the randomness of hash functions
- Problem: cannot satisfy the goal2
- Proposal2: Consistent hash
- We also hash the server's identity
- Description
- The outcome of consistent hashing is really elegant
- How to walk? Clockwise, counter-clockwise, either ok
- What if add a new node?
- move the keys from the original server to new server
- Nice
- TODO: the keys are moved locally
- on average, K/n keys move between two nodes
- Problem
- How to keep balance?
- How to