Skip to Content

Split a massive dataset into smaller pieces spread across servers.

Data Flow (hash-based sharding)

key  ->  hash(key) % N  -> shard_id
user:42 -> hash('user:42') % 4 = 2  -> shard 2

+-------+   +-------+   +-------+   +-------+
| shard0|   | shard1|   | shard2|   | shard3|
+-------+   +-------+   +-------+   +-------+

Strategies

Pitfalls

Analogy

Dividing a phonebook alphabetically across 26 cabinets: range-based gives locality; hash-based by middle name gives even fills.

Interview tip: Always mention hot shard mitigation (replicas, virtual buckets, cache).

Advertisement