A Layer Between App and Data
A database proxy sits between the application and the database tier. The application talks to one endpoint, and the proxy decides which node actually serves each query. This hides topology from the app and centralizes routing logic.
What the Proxy Does
- Read write split Send writes to the primary and spread reads across replicas, automatically.
- Shard routing Inspect the query for the shard key and route to the owning shard, or scatter gather when the key is absent.
- Connection multiplexing Pool and reuse backend connections, as a shared pooler.
- Failover Detect a dead primary and redirect writes to the promoted node without app changes.
Benefits and Costs
The big win is that the application stays topology unaware. Adding replicas, resharding, or failing over happens behind the proxy. Operations become a routing config change rather than a redeploy.
The cost is a new component in the hot path. The proxy adds a network hop and must itself be highly available, or it becomes a single point of failure. Teams run multiple proxy instances behind a load balancer and keep the routing logic fast and stateless.
Key idea
A database proxy centralizes read write splitting, shard routing, and failover so the app stays topology unaware, at the cost of an extra hop that must be made highly available.