Skip to content

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

Neon 7 min read Case study mediumAdept

Cold starts just got hot

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.

Assumes: serverless databasescontrol plane vs data plane

Related posts

  • Zero-Downtime Patching Part 1: Prewarming

    Neon mediumAdept

    Neon and Databricks Lakebase avoid the post-restart performance hit of cold Postgres caches by prewarming a replacement compute before planned maintenance. Shortly before the scheduled restart, the control plane starts a hidden new compute, sends it the list of pages in the primary's cache, and loads them from shared storage. It then tails WAL from Safekeepers, applying only records that touch cached pages, and finally promotes it with pg_promote without restarting the server. In 10 GB pgbench tests, throughput recovers almost immediately with prewarming, compared with a roughly 70% TPS drop and slow recovery on a cold restart, with the largest gain on read-only workloads.

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

    Neon mediumAdept

    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.

  • Simplify Serverless in AWS: How to Use Neon and Ephemeral Environments

    Neon mediumAdept

    Neon's serverless Postgres pairs well with ephemeral environments on AWS Lambda because each environment can get its own instant copy-on-write database branch without paying for extra RDS uptime. Compared with Aurora Serverless v2, Neon claims ~500ms cold starts versus 15s, built-in PgBouncer supporting 10,000 connections, and an HTTP/WebSocket data API. A TODO API built with the Serverless Framework shows how the serverless driver's sql template tag guards against SQL injection, but only when called directly on a string literal, and how sql.query with $n placeholders handles dynamic updates. Scripts and GitHub Actions create a branch per feature or CI run, run unit and end-to-end tests against it, then tear down both the stack and the branch.

  • Scaling serverless Postgres: How we implement autoscaling

    Neon mediumAdept

    Neon autoscales serverless Postgres by running each compute endpoint in a QEMU/KVM VM on Kubernetes (via its NeonVM controller) and hot-adding or removing CPU and memory based on load average. A per-node autoscaler-agent makes scaling decisions but must get every upscale approved by a modified Kubernetes scheduler plugin, which acts as the single source of truth to prevent memory overcommit. Post-copy live migration (~100ms pauses) moves VMs off full nodes, kept cheap by separated storage. Inside each VM, a vm-informant uses cgroup memory.high notifications to freeze Postgres briefly (up to 20ms) while requesting more memory, and resizes a tmpfs-backed local file cache with 1MB LRU chunks that gave one user a 4x speedup.

  • Delayed Start Compute Operations – Triggering Event

    Neon mediumAdept

    Neon's 2025-05-16 us-east-1 outage was triggered when the Postgres planner for the control plane database switched to a suboptimal index for the Activity Monitor query that finds idle Computes to suspend. The resulting broad scan of the tens-of-millions-row computes table saturated CPU and pushed fetchEndpointWithCompute latency from hundreds of milliseconds to over 100 seconds. With suspensions stalled, running VMs grew past the planned 6,000 and IP allocation failed. Neon fixed it by running ANALYZE and wrapping the expensive subquery in a materialized CTE as an optimization fence. Planned follow-ups include more aggressive garbage collection to shrink the table and moving historical data to an OLAP system.

The quest for software engineering knowledge.

Look:
Layout: