Skip to content

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

Neon 14 min read Deep dive hardMaster

Why does Neon use Paxos instead of Raft, and what’s the difference?

Neon replaces Postgres's storage layer with distributed storage, so stateless compute nodes act as Paxos proposers and a fixed set of disk-backed safekeepers act as acceptors. Raft assumes uniform nodes that can each become leader, so it doesn't fit this split. Neon combines a Raft-like term-based election with Paxos-style role separation and recovery, and checks its modifications with TLA+. Competing compute nodes can stall each other, but safekeepers reject WAL from stale terms, so data stays safe while the control plane restores liveness. This avoids the slow 10-30s failovers of Patroni/etcd-style setups.

Related posts

  • Architecture decisions in Neon

    Neon mediumAdept

    Neon built serverless Postgres by separating storage from compute without forking Postgres. Postgres streams WAL over the network to a separate WAL service of safekeeper nodes, which use consensus for durability and to prevent split-brain. Multi-tenant pageservers rebuild any page version on request. All historical page versions are kept in immutable, LSM-inspired files that are compressed and offloaded to object storage like S3, which replaces traditional backups and WAL archives and makes point-in-time recovery and branching cheap.

  • Deep dive into Neon storage engine

    Neon hardMaster

    Neon's storage engine separates Postgres compute from storage and serves pages through GetPage@LSN, reconstructing any page as of any log sequence number from immutable layer files. WAL streams from Postgres to three Paxos-backed safekeepers, then to pageservers that buffer about 1GB of WAL before writing delta layers, building image layers in the background and uploading everything to S3 or GCS. The design borrows from LSM trees but keeps long-lived history, which enables point-in-time restore, copy-on-write branching and fast serverless cold starts without traditional backups or WAL archiving. Compaction and garbage collection bound read cost and retained history, and cold key ranges settle into image layers only.

  • What you get when you think of Postgres storage as a transaction journal

    Neon mediumAdept

    Neon treats Postgres storage as a transaction journal: the write-ahead log becomes the source of truth instead of a recovery aid. WAL is streamed to Safekeepers, which make it durable through Paxos-like consensus, and Pageservers turn it into page versions stored in S3, so compute nodes can stay stateless. Because any page can be rebuilt at any LSN, branching is copy-on-write via a pointer to an LSN, point-in-time restore is a specialized branch, read replicas share the Pageserver instead of copying data, and time-travel queries are possible. A walkthrough of WAL segment naming and pg_waldump output shows the underlying records.

  • Our Approach to High Availability

    Neon easyNovice

    Neon treats high availability as a consequence of separating stateless compute from distributed storage rather than as a paid add-on. Compute failures are handled by automatically restarting Postgres or recreating the VM from a pre-provisioned pool and reattaching the same endpoint, typically within seconds and without changing the connection string. On the storage side, Safekeepers replicate WAL across availability zones, secondary Pageservers keep synchronized copies of project data for failover, and cloud object storage holds the durable primary copy of all data. The same design applies on every plan, including the free tier.

  • SELECT ’Hello, World’

    Neon easyNovice

    Neon is a serverless Postgres service built on separated storage and compute, launching behind a waitlist. Each user gets a containerized Postgres compute node, while data lives in a multi-tenant Rust storage layer: Safekeepers run a consensus protocol and, together with S3, form the system of record, and Pageservers serve pages with low latency as disposable scratch space. Avoiding EBS in favour of local disk for hot data and S3 for cold data cuts the cost of triple-replicated storage and compute. Stateless compute also enables scale-to-zero, roughly 3-second provisioning, and copy-on-write database branching for CI/CD workflows, all released under Apache 2.0.

The quest for software engineering knowledge.

Look:
Layout: