Consistent hashing

hip-hop, educational · 2:46

Listen on 93

Lyrics

[Verse 1]
Started with a simple hash table dream
But when servers crash the whole thing screams
Rehashing everything when nodes go down
Million keys relocating all around
Need a better way to scale this right
Keep the data moving smooth and tight
Enter consistent hashing on the scene
Most elegant solution ever seen

[Chorus]
Ring around the hash space, pocket full of keys
Map them to the circle, distribute with ease
Clockwise to the server, first one that you meet
Consistent hashing magic, makes your system complete
Ring around, ring around, hash space never lies
Add or drop a server, just a few keys fly

[Verse 2]
Picture hash space as a giant ring
Zero to two-fifty-six the range we bring
Servers get their spots upon the wheel
Hash their names and make positions real
Keys get hashed and placed around the band
Clockwise search to find where they will land
First server that you hit becomes the home
No more chaos when your cluster's grown

[Chorus]
Ring around the hash space, pocket full of keys
Map them to the circle, distribute with ease
Clockwise to the server, first one that you meet
Consistent hashing magic, makes your system complete
Ring around, ring around, hash space never lies
Add or drop a server, just a few keys fly

[Bridge]
Virtual nodes solve the balance game
One server claims multiple names
Spread them out across the ring so wide
Even distribution side by side
When machines fail only neighbors care
Adjacent keys need homes somewhere
Hot spots cool and load gets shared
Perfect scaling engineered

[Verse 3]
Amazon Dynamo showed us the way
Cassandra and Riak use it today
Chord and BitTorrent peer-to-peer
Consistent hashing makes it clear
No central point to coordinate
Just local knowledge calculates
Which replica holds your precious data
Fault-tolerant illuminata

[Chorus]
Ring around the hash space, pocket full of keys
Map them to the circle, distribute with ease
Clockwise to the server, first one that you meet
Consistent hashing magic, makes your system complete
Ring around, ring around, hash space never lies
Add or drop a server, just a few keys fly

[Outro]
From rehashing chaos to stability
Consistent hashing sets your data free
O of n down to O of log
Beautiful math cuts through the fog
Ring topology keeps the peace
Scalability will never cease

← Open addressing (linear probing, quadratic probing, double hashing) | Bloom filters →