104
consistent hashing
Adding a node moves only some keys, not all of them. That is the point of the ring.
What is consistent hashing?
Consistent hashing maps keys and nodes onto a ring. A key lives on the next node clockwise. Adding or removing a node remaps only the keys that walked past it, not the entire table. Virtual nodes keep the spread even.
Why does consistent hashing matter when vibe coding?
Models “rebalance” by `hash(key) % N`. Change N and every key moves. Caches empty. Databases rewrite. Say consistent hashing if the set of nodes changes.
How do you do consistent hashing?
Use it for caches and for shard maps that grow. Include virtual nodes. On a miss after a topology change, expect one extra fetch, not a full flush.
How do you ask a model for consistent hashing?
Map (keys) to nodes with consistent hashing, not hash % N. Adding a node must move only a fraction of keys. Use virtual nodes so one real node is not a hotspot.
What goes wrong with consistent hashing?
A ring with three physical nodes and no virtual nodes. One node gets half the keys. The picture looked fair. The histogram is not.