Database Engineering · Scaling the database
Sharding
Sharding puts different rows on different database servers, chosen by a shard key, so writes and data can grow past one machine. The price is routing, cross-shard queries and moving data between shards.
- Time18 min
- LevelDeveloper
- Experiments2 live
- Check6 questions






App runs SELECT for customer 42's orders through the router.
Hash turns 42 into a number and finds the range it falls in.
Shard map says that range lives on shard 3.
Shard 3 answers alone; the other shards never see the query.
App library the app holds the shard map and connects to each shard itself.
Proxy speaks the database protocol and routes queries, like Vitess's VTGate.
Coordinator a database node with shard metadata, like the Citus coordinator.