Consistent Hashing
Posted3 months agoActive3 months ago
eli.thegreenplace.netTechstory
calmpositive
Debate
20/100
Consistent HashingDistributed SystemsAlgorithms
Key topics
Consistent Hashing
Distributed Systems
Algorithms
The post discusses consistent hashing, a technique used in distributed systems to map keys to nodes, and the discussion revolves around its implementation, variations, and related concepts.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
4d
Peak period
13
96-108h
Avg / period
8.3
Comment distribution25 data points
Loading chart...
Based on 25 loaded comments
Key moments
- 01Story posted
Sep 29, 2025 at 4:16 AM EDT
3 months ago
Step 01 - 02First comment
Oct 3, 2025 at 12:17 AM EDT
4d after posting
Step 02 - 03Peak activity
13 comments in 96-108h
Hottest window of the conversation
Step 03 - 04Latest activity
Oct 4, 2025 at 3:07 AM EDT
3 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45411435Type: storyLast synced: 11/20/2025, 8:47:02 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
https://en.wikipedia.org/wiki/Daniel_Lewin
It's so much better to copy and paste the title of articles.
It's also easier to come up with an exact weighted version of rendezvous hashing. See https://en.wikipedia.org/wiki/Rendezvous_hashing#Weighted_re... for the weighted variant.
Faintly related: if you are into load balancing, you might also want to look into the 'power of 2 choices'. See eg https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.... or this HN discussion at https://news.ycombinator.com/item?id=37143376
The basic idea is that you can vastly improve on random assignment for load balancing by instead picking two servers at random, and assigning to the less loaded one.
It's an interesting topic in itself, but there's also ways to combine it with consistent hashing / rendezvous hashing.
[1]: https://pkg.go.dev/github.com/SenseUnit/ahrw
You can do that better if you don't use a random number for the hash, instead flip a coin (well, check a bit of the hash of a hash), to make sure hash expansion works well.
This trick means that when you go from N -> N+1, all the keys move to the N+1 bucket instead of being rearranged across all of them.
I've seen this two decades ago and after seeing your comment, felt like getting Claude to recreate what I remembered from back then & write a fake paper [1] out of it.
See the MSB bit in the implementation.
That said, consistent hashes can split ranges by traffic not popularity, so back when I worked in this, the Membase protocol used capacity & traffic load to split the virtual buckets across real machines.
Hot partition rebalancing is hard with a fixed algorithm.
[1] - https://github.com/t3rmin4t0r/magic-partitioning/blob/main/M...
Isn't that how rendezvous hashing (and consistent hashing) already work?
tl;dr: subdivide your hash space (say, [0, 2^64)) by the number of slots, then utilize the index of the slot your hash falls in.
Or, in another sense: rely on / rather than % for distribution.
Is this accurate or am I missing something?
As a side effect, it's possible to define a logical topology that reflects the physical layout, spreading data across hosts, racks, or by other arbitrary criteria. Things are exactly where you expect them to be, and there's very little searching involved. Combined with a consistent view of the cluster state, this avoids the need for centralized lookups.
The original paper is a surprisingly short read: https://ceph.com/assets/pdfs/weil-crush-sc06.pdf DOI: 10.1109/SC.2006.19
https://github.com/chiefnoah/mehdb
It's used as the index for a simple KV store I did as an interview problem awhile back, it pretty handily does 500k inserts/s and 5m reads/s and it's nothing special (basic write coalescing, append-only log):
https://git.sr.ht/~chiefnoah/keeeeyz/tree/meh
Unless it's a clever play on "consistent", that is. In which case: carry on.
Ketama implementation of consistent hashing algorithm is really intuitive and battle tested.