Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 7 min read How-to mediumAdept

Using Neon’s Scale to Zero with Long-Running Applications

Neon's scale to zero suspends a Postgres compute after an idle window (only when no WAL senders are active and autovacuum isn't running), which severs connections held by long-running servers. A naive node-postgres Client crashes on the resulting unhandled error event. A client-side pg.Pool with an error handler tolerates the dropped connections and reconnects on demand, waking the database. In Apache Bench tests the pool beat per-request connections by more than 10x (about 46ms vs 678ms average latency, 370 vs 26 req/s), with the same pattern shown in a Fastify, Drizzle and HTMX example app.

Assumes: Postgres connectionsNode.js async codeconnection pooling basics

Related posts

  • How Neon's lakebase architecture stays resilient to cloud failures

    Neon mediumAdept

    Neon (and Databricks Lakebase) hardens its serverless Postgres against cloud failures by keeping Postgres compute stateless over zone-redundant storage, so failed computes are replaced instantly without hot standbys or WAL replay. Because agents now start tens of millions of databases daily, the start/suspend path of the control plane is being split into a minimal-dependency data plane controller. Further measures include avoiding cloud provider control planes on the hot path via pre-allocated bare-metal pools and a custom autoscaling virtualization layer, and cell-based regions that limited a May 2026 us-east-1 AZ incident to ~13% of databases. Chaos testing, whole-AZ disconnect simulations targeting under 30s of downtime, and per-database SLIs with 99.99% monthly attainment tracking round out the approach.

  • Quicker serverless Postgres connections

    Neon mediumAdept

    Neon cut the network round-trips needed to get a first query result from its WebSocket-based serverless Postgres driver from nine to four. It moved to TLS 1.3, ran Postgres unencrypted inside a secure wss: WebSocket (or pipelined SSLRequest with the TLS Client Hello), and replaced CPU-heavy SCRAM-SHA-256 with plain password auth over TLS, since Neon only issues long random passwords. It also pipelined the startup, password and query messages into a single send. Pipelining at first added up to 50ms of delay over short distances because of Nagle's algorithm, fixed by setting TCP_NODELAY in the proxy. QUIC-based WebSockets or WebTransport might cut the count further.

  • Let Your AWS Lambdas Survive Thousands of Connections

    Neon mediumAdept

    Lambda's per-instance database connections can overwhelm Aurora Serverless v2 during traffic spikes, causing connection exhaustion, lingering zombie connections and cold-start latency, and RDS Proxy adds cost, pinning issues and borrow latency without fully fixing it. Neon's alternative is PgBouncer built into every endpoint in transaction pooling mode, enabled by adding '-pooler' to the hostname. It accepts up to 10,000 client connections, multiplexes them onto 64 server connections per user/database pair, and queues requests instead of rejecting them. A walkthrough builds a logistics API with a Postgres schema, node-postgres and the Serverless Framework to exercise the pooled setup.

  • Cold starts just got hot

    Neon mediumAdept

    Neon cut serverless Postgres compute cold starts from 3-6 seconds to roughly 500 ms by skipping work and reframing the problem. Idempotent configuration application (1-1.5 s) now runs only when tracked config changes require it, which needed a new model where computes fetch their own config. Pre-started compute pools hand out an empty compute and configure it in a few hundred milliseconds, recycling idle computes and falling back to on-demand creation. Smaller gains came from networking setup changes, caching internal IPs to avoid DNS waits, added concurrency and hot-path optimization. Planned work includes regional control planes and autoscaling computes so one pool can serve all sizes.

  • How Shipsidekick replaced Neon with ClickHouse Managed Postgres for 10x faster queries and better reliability

    ClickHouse mediumAdept

    Shipsidekick, a logistics platform built on Next.js and Vercel, moved its Postgres database from Neon to ClickHouse Managed Postgres after repeated outages. The failures came from connection pool exhaustion across Prisma, Vercel Fluid compute and Neon's PgBouncer, at around 3,000 connections. ClickPipes logical replication moved 500 GB in 4-5 hours. One snag was a partial unique index tripped by mid-flight transactions, fixed by dropping the index and re-creating it after replication. With the bundled PgBouncer, NVMe storage and a single async standby, CPU fell from 100% to 5-10%, cache hit rate rose from 30-35% to 99%, and queries ran about 10x faster. AI agents querying the primary caused CPU spikes, which the team handled with statement timeouts and later a dedicated read replica.

The quest for software engineering knowledge.

Look:
Layout: