0
0
HLDsystem_design~12 mins

Consistent hashing in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Consistent hashing

Consistent hashing is a technique used to distribute data across multiple servers or nodes in a way that minimizes reorganization when nodes are added or removed. It is commonly used in distributed caching and storage systems to ensure scalability and fault tolerance.

Architecture Diagram
User
  |
  v
+----------------+
| Load Balancer  |
+----------------+
        |
        v
+-------------------------+
| Consistent Hashing Ring  |
|  +-------------------+  |
|  | Node 1            |  |
|  +-------------------+  |
|  | Node 2            |  |
|  +-------------------+  |
|  | Node 3            |  |
|  +-------------------+  |
+-------------------------+
        |
        v
+----------------+
| Data Storage   |
+----------------+
Components
User
client
Sends requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to the consistent hashing ring
Consistent Hashing Ring
service
Maps requests to nodes based on hash values to minimize data movement on node changes
Node 1
cache_node
Stores a subset of data determined by consistent hashing
Node 2
cache_node
Stores a subset of data determined by consistent hashing
Node 3
cache_node
Stores a subset of data determined by consistent hashing
Data Storage
database
Persistent storage for data not found in cache nodes
Request Flow - 6 Hops
UserLoad Balancer
Load BalancerConsistent Hashing Ring
Consistent Hashing RingCache Node (Node 1/2/3)
Cache NodeData Storage
Data StorageCache Node
Cache NodeUser
Failure Scenario
Component Fails:Cache Node (Node 2)
Impact:Requests mapped to Node 2 fail to retrieve data from cache, causing increased load on database and higher latency
Mitigation:Consistent hashing ring remaps keys to remaining nodes; replication or virtual nodes reduce impact; fallback to database ensures availability
Architecture Quiz - 3 Questions
Test your understanding
What is the main benefit of using consistent hashing in this system?
AEnsures all data is stored on a single node
BEliminates the need for a load balancer
CMinimizes data movement when nodes are added or removed
DMakes database queries faster
Design Principle
Consistent hashing allows distributed systems to scale smoothly by minimizing data reallocation when nodes change, improving availability and reducing downtime during scaling or failures.