With sharding, the application needs to know which shard to query. A database proxy handles this.
Proxy responsibilities:
- Route queries to correct shard
- Handle cross-shard queries (scatter-gather)
- Connection pooling
- Read/write splitting
Popular proxies:
- Vitess (MySQL, used by YouTube)
- ProxySQL (MySQL)
- Citus (PostgreSQL)
- PgBouncer (PostgreSQL, pooling only)
Application-level routing: Alternative where the app determines the shard. Simpler setup but routing logic in every service.
Mention Vitess or ProxySQL when discussing MySQL sharding at scale.