All examples

Examples

Which keys move when a cache server joins

Three cache servers and four keys hashed onto a ring, each key going to the next server clockwise; a fourth server joins and only one key moves to it.

This video was made with the System design skill.

  • 0:58
  • System design
  • Narrated by Kore
  • English

Made from a prompt

Explain consistent hashing with a hash ring: which keys move when a server is added?

Video transcript

Adding one cache server should not force every cached key to move.

We hash cache server A onto a circle, then place servers B and C.

Now hash apple, book, cat, and dog onto that same circle, using their keys.

Each key belongs to the first server clockwise around the ring. So dog wraps past the top to A.

What happens when you need more capacity? Add server D between A and B.

Only book moves from B to D; its hash falls between A and D.

With uniform hashes, adding a fourth server moves about one quarter of keys on average. Real caches must refill moved entries.

Keys mark data; servers own the preceding clockwise interval. Adding D changes only its new interval, keeping other owners stable.

Your topic, drawn in about a minute.

Your first 2 videos are free, up to 1 minute each, watermarked. No card required. Full product, every voice and style included.