Clockwise Key Assignment Rule
What You'll Learn
You'll learn exactly how a key finds its home node on a consistent hash ring—by traveling clockwise until it meets the first available server.
The Core Idea
In consistent hashing, both keys (data items) and nodes (servers) are mapped to positions on a circular hash ring using the same hash function. Once you've positioned a key on the ring, the clockwise key assignment rule determines which node stores that key: the key is assigned to the first node encountered when moving clockwise from the key's hash position.
Think of it like a circular parking lot where you enter at a specific spot and walk clockwise until you find the first available parking space—that's where you park.
How It Works
- Hash the key: Apply your hash function to get a position on the ring (e.g., key
"user:42"→ position87) - Start at that position: Locate where
87sits on the 0–359 ring - Move clockwise: Scan in the clockwise direction
- Stop at first node: Assign the key to the first node you encounter
Example
Ring positions:
- Node A at position 50
- Node B at position 150
- Node C at position 280
Key "user:42" hashes to position 87
→ Move clockwise from 87
→ First node encountered: Node B (at 150)
→ Assign "user:42" to Node B
This simple rule ensures deterministic placement—any client performing the same calculation will route the request to the same node, with no need for a central coordinator.
Key Takeaway:
The clockwise key assignment rule provides a deterministic, decentralized method for mapping keys to nodes: always walk clockwise from the key's hash position to the first node on the ring.