How to Scale Neon Postgres
From MVP to IPO on a single connection string.
TL;DR
Scaling Neon requires two things: Connection Pooling (pgbouncer) to handle serverless function spikes, and appropriate Compute Autoscaling limits. Don't connect directly to the main Postgres port from a Lambda function.
Scaling Limits & Configuration
| Metric | Direct Connection | Pooled Connection |
|---|---|---|
| Max Connections | ~100 (Risky) | 10,000+ |
| Latency | Low | Low (Negligible overhead) |
| Ideal For | Long-running migrations | API Routes / Server Actions |
Autoscaling Compute
Neon can scale your compute up and down instantly. Set your autoscaling limits high enough to handle spikes, but low enough to protect your wallet.
Connection Pooling
Serverless functions exhaust connections fast. Always use the pooled connection string (`-pooler`) in your production env vars.