Connection Pooling
Connection pooling is maintaining a set of open, reusable connections to a database or upstream service so requests can borrow an existing connection instead of opening a new one. It avoids repeated TCP and TLS handshakes and prevents exhausting server connection limits.
Technical Architecture & Deep-Dive
Opening a Postgres connection or a TLS session costs several round trips. Under load, creating a connection per request wastes time and can exceed database limits.
Serverless and edge functions are short-lived, so they rely on external poolers such as PgBouncer, Neon pooled endpoints, or platform-managed upstream connection reuse. Edge networks keep warm connections to popular API providers, so proxied calls skip handshake costs.
Key Architectural Benefits
Implement Connection Pooling at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:Why do serverless functions exhaust database connections?
Each concurrent invocation may open its own connection. Without a pooler, traffic spikes create thousands of connections that databases cannot handle.
Related Architecture Concepts
HTTP keep-alive, or persistent connections, keeps a TCP connection open after a response so subsequent requests to the same host reuse it. This avoids repeating TCP and TLS handshakes for every request, significantly reducing latency for clients that call the same API repeatedly.
TLS handshake latency is the delay caused by negotiating an encrypted HTTPS connection before any application data is sent. The client and server exchange messages to agree on ciphers and verify certificates, costing one or more network round trips on top of TCP setup.
HTTP/2 multiplexing allows multiple requests and responses to travel concurrently over a single TCP connection as interleaved streams. Unlike HTTP/1.1, which processes one request per connection at a time, HTTP/2 removes the need for many parallel connections and reduces latency.