Consistent Hashing
Quick Reference: Load Balancing | Hashing Internals | Step 2: Sharding
Quick Reference
| Aspect | Traditional Hashing | Consistent Hashing |
|---|---|---|
| Rebalancing | Rehash all keys | Minimal key movement |
| Adding Server | All keys move | Only nearby keys move |
| Removing Server | All keys rehash | Only affected keys move |
| Use Case | Static servers | Dynamic server changes |
Clear Definition
Consistent Hashing is a hashing technique that minimizes key redistribution when servers are added or removed. Keys are mapped to a hash ring, and each server handles keys in its range.
š” Key Insight: Consistent hashing enables dynamic scaling with minimal data movement, essential for distributed caching and databases.
Core Concepts
Hash Ring
- Keys and servers mapped to ring
- Each server handles keys clockwise from its position
- Adding/removing server affects only nearby keys
Virtual Nodes
- Multiple virtual nodes per physical server
- Improves distribution uniformity
- Reduces hotspots
Use Cases
- Distributed Caching: Redis, Memcached clusters
- Load Balancing: Request routing
- Database Sharding: Data distribution
- CDN: Content routing
Best Practices
- Use Virtual Nodes: Improve distribution
- Monitor Distribution: Check for hotspots
- Handle Failures: Replicate data across nodes
Quick Reference Summary
Consistent Hashing: Hash ring minimizes key movement when servers change.
Key Benefit: Dynamic scaling with minimal rebalancing.
Use For: Distributed caching, load balancing, sharding.
Previous Topic: Load Balancing ā
Next Topic: Hashing Internals ā
Back to: Step 6 Overview | Main Index