You are designing partitioning for a distributed key-value store that must grow and survive node failures without downtime. How do you use consistent hashing, and what else do you need?
Sketch your own answer first, then compare it with the one below.
A strong answer
Use a ring with virtual nodes so that adding or removing a node moves a small, spread-out share of the data and load stays reasonably even. Weight virtual node counts by machine capacity.
Then cover what the ring does not provide:
- Replication on the next distinct physical nodes clockwise, respecting racks or zones.
- Membership and failure detection, so every node has a consistent enough view of the ring. Gossip is a common mechanism.
- Data movement when membership changes: stream the affected ranges to new owners in the background, throttled so that it does not hurt foreground traffic, and only switch ownership when the data is there.
- Handling temporary failures separately from permanent ones, so a brief outage does not trigger a full rebalance.
- Hot keys, which hashing cannot spread. Use caching in front, splitting a key into parts, or special handling.
- Operational visibility: per-node key counts, request rates, and the imbalance over time.
Pin down the consistency model and how clients find the ring, since the ring alone answers neither.
Sources
- Giuseppe DeCandia, Deniz Hastorun, Madan Jampani, Gunavardhan Kakulapati, Avinash Lakshman, Alex Pilchin, Swaminathan Sivasubramanian, Peter Vosshall, Werner Vogels (2007). Dynamo: Amazon's Highly Available Key-value Store.
- Avinash Lakshman, Prashant Malik (2010). Cassandra: a decentralized structured storage system.