Skip to content
Theory · Choosing and splitting storage · lesson 5 of 7

Consistent hashing

The classifieds service's chat keeps growing, and four shards will soon not be enough. Adding a fifth is not hard in itself: set up one more database. The hard part is how many messages have to move when you do. Consistent hashing answers this so that only a small part of the data moves. Interviewers like to ask about this technique.

In this lesson

  • Why not modulo
  • The ring
  • An example with four nodes
  • Virtual nodes
  • Where you meet it
  • Common mistake
  • Key points