System Design interview question

What is consistent hashing?

Short answer

Consistent hashing places both servers and keys on a hash ring; each key belongs to the next server clockwise. When a server is added or removed, only the keys between it and its neighbour move, instead of almost every key as with hash-mod-N. Virtual nodes give each server several positions on the ring to balance load.

Where it is used

  • Distributed caches deciding which node stores a key.
  • Partitioned databases assigning data ranges to nodes.
  • Load balancers that need request affinity.

How to answer it in an interview

  • Draw the ring and move one server to show the limited reshuffle.
  • Explain why virtual nodes reduce hot spots.

Walk into your next interview prepared

Start free, install the Windows app and run a practice session today.