A partitioning key determines where an item or record is placed. In an interview, distinguish it from replication: sharding splits distinct data across nodes for scale, while replication copies data for availability and read throughput. section 6.5
Evaluate a candidate key against the main operational trade-offs:
- Spread data and traffic evenly instead of creating hot shards through low-cardinality or skewed values. section 6.5
- Avoid monotonically increasing or time-based values that direct new writes to one node. section 6.5
- Align the key with query patterns so common lookups reach one shard rather than producing fan-out requests. section 6.5
Interview follow-up
When asked how to choose a shard key, explain that the choice controls data and traffic distribution. Compare even distribution against query locality, then discuss hotspots, write concentration, and fan-out risk. section 6.5
Table 6.6 Data replication, sharding, and partitioning
|
Topic
|
Fundamentals
|
Applied skills
|
Advanced
|
|
Data replication
|
Understand that data is copied across nodes to improve availability and fault tolerance.
|
Use leader-follower or multi-leader replication. Tune sync vs. async replication. Handle stale reads and conflicts.
|
Optimize replication lag, implement quorum reads/writes, and reason about consistency in geo-replicated systems.
|
|
Sharding (horizontally partitioning)
|
Understand that data is split across multiple databases or nodes, usually by key.
|
Implement horizontal scaling using range-based or hash-based sharding. Handle rebalancing and routing logic.
|
Design for cross-shard transactions, hotspot detection, and dynamic resharding without downtime.
|
|
Partitioning
|
Know that partitioning divides data into independent subsets for manageability and parallelism.
|
Apply vertical vs. horizontal partitioning. Use partitioning to reduce query latency and contention.
|
Design partition-aware data models and query strategies. Handle skew, repartitioning, and partition pruning at scale.
|
Use the comparison table to connect partition keys with horizontal sharding, range- or hash-based distribution, routing, rebalancing, and hotspot detection. section 6.5










