Serverless and edge environments exhaust database connections without a pooler. Use PgBouncer, Supavisor, or platform-native pooling.
Why This Matters
Each database connection consumes ~10MB of RAM. Without pooling, serverless functions can open hundreds of simultaneous connections, crashing the database.
Serverless environments (Vercel, AWS Lambda, Cloudflare Workers) create a new database connection per request. PostgreSQL defaults to max_connections = 100, which is quickly exhausted.
Platform-Specific Solutions
Supabase
// Use the pooler URL (port 6543), not the direct connection (5432)const supabase = createClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!);// Supavisor handles pooling automatically via the API
Neon
import { neon } from '@neondatabase/serverless';const sql = neon(process.env.DATABASE_URL!); // Uses HTTP, no persistent connection
PlanetScale
import { connect } from '@planetscale/database';const conn = connect({ url: process.env.DATABASE_URL }); // HTTP-based, no connection limit