System Design Patterns: From Fundamentals to Real Systems
Vote

0% completed

Consistent Hashing

1. The Incident

The sharding worked. Four shards, keyed by hash(customer_id) % 4, each one at a comfortable 625 writes per second. Two years later, growth says you need a fifth.

So you change the routing rule: % 4 becomes % 5. The percent sign is the modulo operation: it keeps the remainder after division. Before deploying, someone on the team does the arithmetic on that small edit. A key stays on its current shard only if hash % 4 and hash % 5 happen to agree. For random hashes they agree only 20% of the time

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%