DB connection pooler
Amazon RDS Proxy
Multiplexes thousands of client connections onto a few database connections.
In a monolith
Pool inside the app
A connection pool in the app (SQLAlchemy, HikariCP) is plenty for a few instances.
In a distributed system
Shared pooler
With dozens of services or thousands of functions, a central pooler protects the database’s connection limit and smooths failovers.
On AWS
Amazon RDS Proxy
Managed pooling for RDS/Aurora. Essential with Lambda, where each concurrent invocation may open its own connection; also shortens failovers.
- RDS Proxy$$Managed, IAM auth, faster failovers
- PgBouncer on ECS/EC2$Self-managed transaction pooling
- Reach for it when
- Connection count — not query load — is what’s exhausting the database (serverless or many instances).
- What it costs you
- One more hop
- Transaction pooling breaks some session features (prepared statements, session variables)
- When it dies
- If the pooler dies the DB is unreachable — run it redundantly (managed proxies are).
Interview follow-ups
Why does Lambda + RDS need a proxy?
Each concurrent Lambda can hold its own connection; a spike to a thousand concurrent invocations can exceed the DB’s max connections. The proxy pools them.
Connection rules
It talks to
Gets traffic from
Never
- Clients → DB proxySame as the database: clients get no DB credentials or direct DB access.
- CDN → DB proxyCDN origins are HTTP servers or buckets, never databases or caches.
- Load balancer → DB proxyA load balancer forwards HTTP to compute. Data access needs code: auth, queries, validation.
- API gateway → DB proxyA gateway routes to compute; data access needs your code.
- Queue → DB proxyQueues don’t run code. A consumer reads the message and does the write or call.
- Pub/sub topic → DB proxyTopics don’t run code. A subscriber receives the event and does the write.
- Event stream → DB proxyStreams don’t run code. A consumer reads the records and does the write or call.