Consistent Hashing is not some magical solution that fits everywhere. Let me tell you one place where you should never use consistent hashing ⚡
Consistent Hashing fails miserably when you need to support Range Queries across the dataset. For example: select all the keys from the KV store that lies in the range [A, C].
⚡ Consistent hashing is a technique based on Hashing, and hence the distribution of the keys in the cluster is governed by the underlying Hashing function.
Evaluation of such range queries will require expensive cross-shard queries and some coordinator stitching the data before sending it back.
This kind of query is best answered when the data is laid out in order.
Always remember, no concept in Computer Science is perfect; Everything just boils down to trade-offs.
Remember this the next time someone says “I will use consistent hashing”, just ask “why?”. Very few people have the answer 🙃
⚡ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.
I have covered Consistent Hashing in-depth in the Beginner Friendly System Design course. So, if you are inclined towards learning real System Design, check it out 👇
arpitbhayani.me/sys-design