In plain words
A connection pool keeps a fixed number of database connections open and lends them to requests in turn, because opening a connection is slow and a database like Postgres can only hold a limited number.
Where you see it
During a traffic spike Harbor's logs fill with "FATAL: sorry, too many clients already". Each serverless function opened its own Postgres connection until the database hit its limit. PgBouncer in transaction mode lets thousands of clients share 40 server connections.
What goes wrong
- A pool per instance, multiplied
A pool of 10 sounds small until 30 instances and two workers each open one. Add them up across everything that connects, and keep the total under the database's limit with room for admin tools and migrations.
- Session features through a transaction pooler
In transaction mode your next transaction may run on a different server connection, so session-level SET, advisory locks and LISTEN misbehave. Older PgBouncer versions also broke prepared statements, so check what your version and driver support.
- Holding a connection while waiting on something else
Code that opens a transaction and then calls Stripe for two seconds keeps a pooled connection busy the whole time. Make slow outside calls before or after the transaction, not inside it.
What to tell your agent
Quick check
Sign in to earn +10 XP for itHarbor runs 25 API instances, each with a pool of 10 connections, against a Postgres server whose max_connections is 100. What happens at peak?