Skip to content

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

Neon 15 min read Deep dive hardMaster

WAL + S3: Lakebase storage for the era of agents

Lakebase Postgres (Neon's architecture) treats the Postgres write-ahead log as the source of truth and data pages as a derived cache, splitting the system into stateless compute running unmodified Postgres and a storage layer of Paxos-replicated safekeepers, pageservers, and S3. Commits are acknowledged once a quorum of safekeepers has the WAL, while pageservers asynchronously materialize immutable image and delta layers into object storage and serve GetPage@LSN requests by replaying WAL onto the nearest image. Finding the right layer among tens of millions uses a persistent binary search tree with path copying, so historical reads at any LSN cost the same as latest reads. Because queries hit RAM, local NVMe, then the pageserver, and never S3 directly, the design avoids object-storage latency while making branching, instant point-in-time restore, and time-travel queries pointer operations whose cost does not depend on database size.

Related posts

  • 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.

  • Lakebase Postgres is built on object storage, but 99.99999% of reads never touch it

    Neon mediumAdept

    Lakebase Postgres stores durable history in object storage but keeps it off the read path through tiered caching. Production fleet stats show the compute's local cache serving ~1.1B page accesses/sec (99.46%), pageserver NVMe ~6M/sec (0.54%), and object storage only ~39 requests/sec, about 1 in 28 million reads, mostly from long-dormant project wakeups or branches and restores at old LSNs. Pageservers answer GetPage@LSN by replaying delta layers on top of the nearest image layer. Creating image layers more eagerly keeps p90 under 1 delta and p99 around 6 per read.

  • 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.

  • Point In Time Recovery Under the Hood in Serverless Postgres

    Neon mediumAdept

    Neon implements point-in-time recovery by treating Postgres as its WAL. WAL is streamed to Paxos-backed Safekeepers, then to multi-tenant Pageservers that build immutable image and delta layers keyed by key range and LSN. The post contrasts this with traditional Postgres PITR, which needs base backups, WAL archiving, tools like Barman and a standby server. Neon's GetPage@LSN instead rebuilds any page at any LSN on demand. Time Travel Assist uses this through ephemeral copy-on-write branches with a 10-second TTL, so you can query a past state before restoring.

The quest for software engineering knowledge.

Look:
Layout: