ZZomato·BehavioralSenior SWESystem Design

What Is Database Sharding?

viaGlassdoor

Q: What is sharding?

A: Sharding is a technique for horizontally partitioning a large dataset across multiple database instances ("shards"), where each shard holds a subset of the overall data.

Key points to cover:

  • A shard key (or partition key) determines which shard a given row/document lives on; common strategies include range-based, hash-based, and directory-based sharding.
  • Benefits: distributes read/write load across machines, allows storage to scale beyond a single node's capacity, and can improve query latency by keeping working sets smaller per shard.
  • Trade-offs: cross-shard joins and transactions become expensive or require special handling; rebalancing shards (e.g., after adding nodes) can be operationally complex; a poorly chosen shard key can create hot shards.
  • Contrast with replication: sharding splits data (each shard has different data), while replication copies the same data across nodes for availability/read-scaling.
Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account