Background
Consistent hashing is a partitioning strategy that involves placing hash codes on a number circle (“hash ring”) with
Xu introduces consistent hashing as an unalloyed good, dedicating an entire chapter to it (ch. 5). On the other hand, Kleppman says that, in practice, it’s a lousy strategy for partitioning and is rarely used (p. 330), favoring either Dynamic partitioning or using a huge number of partitions.
It’s not clear to me why Kleppman considers these to be either/or; you still need a way to decide which of your (dynamic or virtual) partitions you’re going to put something in, and consistent hashing is one way to do that.
Implementation
To start, you need to identify the range of your hash function. For example, SHA-1’s range is
In the event that you need to add or remove a partition, you need to reassign
You can use consistent hashing with virtual partitioning by creating