Medium System Design Database Design
What are database sharding strategies and their trade-offs?
Answer
Sharding horizontally partitions data across databases. Strategies: Range-based (by value ranges - easy but hotspots), Hash-based (consistent hash of key - even distribution, no range queries), Directory-based (lookup table - flexible but overhead), Geographic (by region - data locality). Trade-offs: cross-shard queries are expensive, joins limited, transactions complex, rebalancing difficult. Implementation: application-level routing, proxy layer (Vitess), or native support (CockroachDB). Consider: shard key selection critical, avoid hotspots.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Software Engineer Database Architect Backend Developer