How it works
Partitioning, also called sharding, splits the key space so each node stores only part of the data. Hash each key to a partition and route requests to its owner. Consistent hashing places keys and node positions on a ring; a key maps to the next owner clockwise. Virtual nodes, which are several ring positions for one machine, distribute ownership more evenly and let larger machines take more ranges. Clients or coordinators (nodes that handle a request on a client’s behalf) need a current membership map during changes.
When a node joins, only the ranges it takes need to move. In an example cluster of six nodes holding 6 TB, a seventh node takes about one seventh of the data, roughly 860 GB, where plain hash(key) mod N would reassign most keys. That transfer still costs network and disk capacity: at 100 MB/s, 860 GB takes about 2.4 hours.
Watch for hot keys: balanced key counts do not guarantee balanced request load. A popular key has one logical home however many virtual nodes exist. Replication and caching can help reads, but a write-hot key may require a different data model. Hash partitioning also gives up range scans, because neighboring keys land far apart. Range partitioning, as in Bigtable and HBase, keeps keys sorted so scans stay cheap, at the cost of hot spots when new keys arrive in sequence, such as timestamps.
One key receives a third of all writes, though key counts are evenly distributed. Will more virtual nodes solve it?
No. Virtual nodes balance ranges, but that key still has one logical home. Consider splitting the logical write across keys or changing the write model.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Partitioning distributes data; it does not create a safety copy.
- Virtual nodes balance ranges, while hot keys need workload-specific treatment.