Sharding & partitioning · TL;DR
1 min readTL;DR
Sharding splits one dataset across many machines so that writes, storage and hot working sets that no longer fit one node can scale out. Every sharded design answers four questions. How are keys mapped to shards — by hash (even spread, no range scans), by range (range scans, hot spots on sequential keys), or through a directory (flexible, one more lookup)? What is the shard key — the field most queries filter on, with high cardinality and even load? How do you add capacity — consistent hashing or fixed virtual partitions so that only a fraction of data moves, and an online migration that never stops writes? What happens to queries that span shards — avoid them by key choice, or pay for scatter-gather and secondary indexes. Shard late: replicas, caching and a bigger box buy years before the complexity is worth it.