Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Consistent Hashing
FUNDAMENTALS & NETWORKING · SUBTOPIC

Modulo Hashing vs. Consistent Hashing

See why hash % N causes massive cache misses during scaling and how the ring moves only 1/N keys.

IntermediatePart of Consistent Hashing
Practice in AI HLD
Subtopics in Consistent Hashing (2)
OverviewModulo vs. RingVirtual Nodes

In plain words

With modulo, adding one shelf makes you re-sort almost every book in the library. With a hash ring, you only slide a small slice of books onto the new shelf.

Think of it like…

Re-seating an entire stadium whenever one person arrives vs. letting one row shift slightly.

Loading interactive diagram
Loading interactive exercise

Theory & how it works

The exact math of key movement

With N nodes, adding 1 node in consistent hashing moves approximately K / (N + 1) keys on average (where K is total keys). With 10 nodes, adding an 11th node moves only ~9% of keys instead of ~91% under modulo.

Key points & practical guide

Summary checklist

  • Modulo (% N) remaps nearly everything on cluster resize
  • Consistent hashing moves only ~1/N keys
  • Lookup takes O(log V) with binary search over sorted ring positions

When to use it

  • Distributed caches (Memcached/Redis)
  • Partitioned NoSQL stores (Cassandra, DynamoDB)
  • Stateful routing / sticky edge routing

Watch out for

  • Hot keys (celebrities) still hit one node regardless of ring balance - replicate hot keys separately

Quick check

Loading quiz
Parent topic
Consistent Hashing
Next subtopic
Virtual Nodes & Hot-Spot Mitigation