All posts
Internet Fundamentals

Too Many Connections: Database Pooling for Serverless and Edge Apps

By

October 26, 2026

5 min read

Postgres gives every connection its own process and a fixed maximum, while serverless platforms create a new instance, and a new connection, for each concurrent request. The result is the classic launch-day error. How the limits are set on RDS and Supabase, what a pooler does, and the transaction-mode catch.

Internet Fundamentals
PostgreSQL
Connection Pooling
Serverless
Amazon RDS

A traditional server opens a pool of perhaps 10 connections and shares them across thousands of requests. A serverless function cannot share: each concurrent instance holds its own. At 300 concurrent requests you can have 300 connections, and PostgreSQL's default max_connections is 100.

Where the limit comes from

  • PostgreSQL runs a server process per connection, so each costs memory even when idle.

  • On RDS for PostgreSQL the default is LEAST({DBInstanceClassMemory/9531392}, 5000): about 110 connections per GiB of memory, less what RDS reserves. Small instances allow a few dozen to a couple of hundred.

  • Raising max_connections without more memory swaps a connection error for memory pressure.

Want a second opinion on this for your system?

Book a free 30-minute call. You'll leave knowing what we'd do first and roughly what it costs, whether or not you hire us.

What a pooler does

A pooler accepts many client connections and multiplexes them onto a few real ones. In transaction mode, a real connection is lent out for one transaction and returned, so hundreds of functions can share twenty connections.

Option

Fits

Catch

Supabase shared pooler, transaction mode (port 6543)

Serverless and edge functions

No prepared statements: turn them off in your client library

Supabase direct connection (port 5432)

Long-running servers and containers

IPv6 by default; IPv4 needs the add-on or the session-mode pooler

Amazon RDS Proxy

Lambda or containers against RDS and Aurora

An hourly charge; some session features pin a client to one connection and reduce sharing

PgBouncer you run

Any Postgres, full control

Another service to run, patch and keep available

HTTP-based drivers (Neon's serverless driver, the RDS Data API for Aurora)

Edge runtimes without TCP sockets, very spiky traffic

Per-request overhead; not every ORM supports them

Habits that help regardless

  • Create the database client outside the handler so a warm instance reuses its connection.

  • Set the pool size inside each function to 1 or 2. Ten per instance multiplies the problem.

  • Set statement and idle timeouts so one stuck query does not hold a connection indefinitely.

  • Graph active connections and alert well below the limit.

hoolco Monthly Review

Once a month: what changed in tech that month and what it means for you, from cloud and AI to security and the tools you build with. Every item links to its source. No sales pitch, unsubscribe in one click.

As of October 26, 2026. Provided as is, for general information, and accurate to the best of our knowledge on the date shown. Not legal, compliance, tax, financial or other professional advice. Prices, limits and vendor services change; check current vendor documentation before relying on anything here. Terms of use.