RDS Proxy: How Connection Pooling Actually Works
~10 min read
Why serverless/highly concurrent clients need pooling, and what RDS Proxy does differently from an application-level pool.
A relational database has a hard cap on concurrent connections, set by the instance class (larger instances allow more connections, but the cap is always finite). A traditional server with a small, stable pool of long-lived connections rarely hits this cap. Lambda breaks that assumption: each concurrent Lambda invocation can open its own new database connection, and during a traffic spike, hundreds of simultaneous invocations can open hundreds of simultaneous connections almost instantly, exhausting the database's connection limit and causing errors for every client — including ones that aren't part of the spike. RDS Proxy sits between clients and the database, maintaining its own smaller, stable pool of actual database connections and multiplexing many client-facing logical connections onto that pool, only opening a new physical connection to the database when genuinely needed. It also improves failover behavior: because RDS Proxy itself holds the connections, an application doesn't need to detect a failover and reconnect — RDS Proxy handles re-establishing connections to the new primary transparently, often faster than an individual client's own reconnect logic would.
💬 Deep Dive with AI
Key points
- •Databases have a hard, instance-size-dependent cap on concurrent connections
- •Lambda's concurrency model can open many connections almost instantly, exhausting that cap
- •RDS Proxy pools and reuses a smaller set of actual database connections behind many client-facing logical ones
- •RDS Proxy also speeds up failover, since it manages reconnection to the new primary on the client's behalf