Each record's key is run through a hash function, and the result picks its node. Hashing scatters similar keys, so records and requests spread evenly, and any part of the system can compute where a key lives without asking anyone. The catch is what happens when the number of nodes changes. Below, compare plain hash mod N with fixed hash slots, and add or remove nodes to see how much data moves.
Each dot in a node is one user record, coloured by country. Add or remove a node and the records that change node glide to their new place, ringed so you can count them; the count appears under the app. A node turns red when it serves well above its share of requests.
1. Total data
2. Nodes, filled to 70%
3. Adding one node with hash mod N
4. Adding one node with fixed slots
Step 1 is the storage estimate from the back-of-the-envelope chapter of Alex Xu's System Design Interview, Vol. 1. Step 3 follows from how modulo behaves: for a well-mixed hash, the remainders by N and by N + 1 agree for about 1 key in N + 1. Step 4 assumes each node holds the same number of slots, which the rebalancing keeps true to within one slot.
Redis exposes its slots; DynamoDB hides its partitions but warns about hot keys.
CRC16(key) mod 16384. "Adding or removing a node is abstracted into the same operation: moving a hash slot from one node to another." Hash tags keep related keys together: {user1000}.following and {user1000}.followers land in the same slot, because only user1000 is hashed.All are official documentation: the Redis Cluster specification and Amazon's DynamoDB developer guide. Quoted phrases are short attributed quotations; everything else is described in our words.