Data at Scale · 10 min read · Intermediate
Sharding, Partition Keys & Consistent Hashing
Scale write-heavy datasets beyond one machine using horizontal sharding, good shard keys, and consistent hashing.
What you'll learn
- Choose high-cardinality shard keys to avoid hot partitions
- Understand cross-shard join and transaction limitations
- Minimize key movement during resharding with consistent hashing
Overview
Scale write-heavy datasets beyond one machine using horizontal sharding, good shard keys, and consistent hashing.
Great system design is about explicit trade-offs rather than memorizing buzzwords. Every architectural layer you add (caches, replicas, queues, shards) solves one bottleneck while introducing new operational failure modes.
Design Checklist
| Dimension | Questions to Ask |
|---|---|
| Traffic & Scale | What is the read-to-write ratio, peak QPS, and payload size? |
| Consistency | Can users tolerate eventual consistency for a few seconds, or do we need strict ACID? |
| Failure Modes | What happens if a cache node, replica, or downstream API times out? |
| Simplicity | Can a single well-indexed PostgreSQL instance handle the next 12 months of growth? |
Key Takeaways
- Choose high-cardinality shard keys to avoid hot partitions
- Understand cross-shard join and transaction limitations
- Minimize key movement during resharding with consistent hashing
Quick Check
Check Your Understanding
Score: 0 / 1
1. What happens if you shard an orders table by `country` when 80% of your users live in one country?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.