Try
↑ ↓ move↵ openesc close

Interview prep / Consistent hashing

Senior · Consistent hashing · System design interview question

What is jump consistent hash, and when would you use it instead of a ring?

Sketch your own answer first, then compare it with the one below.

A strong answer

Jump consistent hash maps a key to one of N numbered buckets using a short loop and a pseudo-random sequence seeded by the key. It needs no stored ring and almost no memory, and it is fast.

It keeps the key property of consistent hashing: when N grows by one, only the keys that move to the new bucket change owner, which is about one over the new count of keys. Balance is very even, without virtual nodes.

The restriction is that buckets are numbered 0 to N-1. You can add or remove buckets only at the end. You cannot remove an arbitrary one in the middle, which is what happens when a server fails. Nor can it express weights directly.

So it fits systems with numbered shards that grow, such as a sharded storage service where a failed shard is replaced rather than removed, or where a separate mapping from bucket to machine handles failures. A ring, or a ring-like structure such as rendezvous hashing, fits clusters where arbitrary members come and go.

State versus flexibility is the whole trade.

Sources

Learn it by running it

The consistent hashing lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms