PrepZone Logo
PrepZone
Back to Database

Database · Hard

How does consistent hashing work for sharding and cache distribution?

DatabaseDistributed SystemsStaff

Answer preview

Consistent hashing maps both keys and nodes onto the same circular hash space, and assigns each key to the first node found clockwise from it. Adding or removing a node only remaps the keys in that node's arc — roughly K/N keys — instead of nearly all of them.…