Databases

Consistent hashing

A way to decide which shard each piece of data goes to that, when a shard is added or removed, moves only part of the data.

Example

With 4 shards, adding a fifth moves about 1/5 of the data. With a plain hash (id % 4 → id % 5) almost all of it would move.

Test yourself: Consistent hashing

Consistent hashing

You split with hash % N. What happens if you add a node?

Lessons that use it

More databases terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.