Repaso
EspaƱol
System DesignAdvancedSD-08

Why use consistent hashing to distribute keys across cache nodes?

Options

  1. It encrypts the keys that are stored in the cache
  2. A node change remaps only about 1/N of the keys (Correct option)
  3. It guarantees perfect balance without virtual nodes
  4. It removes the need for replication entirely

Answer

Adding or removing a node remaps only about 1/N of keys instead of nearly all

Why

With hash(key) % N, adding one server changes N, so almost every key suddenly maps to a different server: the whole cache is effectively lost.

Consistent hashing places servers and keys on a circle; each key goes to the next server clockwise. Adding a server only takes over the keys between it and its neighbor, about 1/N of them.

'Virtual nodes' (several points per server) spread the load evenly.

Remember

Consistent hashing = adding a node moves few keys.

Key terms

Practice this question in Repaso