Skip to content

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

Neon 5 min read Case study mediumAdept

How we scale an open source, multi-tenant storage engine for Postgres written in Rust

Neon shards its Rust-based Pageserver storage layer by dividing each Postgres relation's 8KiB block numbers into stripes (default 256MiB) and hashing each stripe to a Pageserver. Large tenants then get I/O that scales with dataset size, and they stop competing with small tenants for resources. All shards subscribe to the Paxos-based Safekeepers and filter WAL down to their own pages, while Postgres routes GetPage@LSN reads directly to the right shard by hashing, with no proxy in between. Tables need to exceed stripe size × shard count (e.g. 2GiB with 8 shards) to use full throughput. Planned work includes shard-aware Safekeepers to cut WAL fan-out cost and shard splitting, since shard count is currently fixed at tenant creation.

Assumes: Postgres WAL and pagessharding basicsseparation of storage and compute

Related posts

  • Recent Storage Performance Improvements at Neon

    Neon hardMaster

    Neon shipped a set of storage-layer optimizations across Safekeepers and Pageservers. WAL is now decoded once at Safekeepers and routed only to the relevant shard, which roughly doubles ingest throughput for large tenants. Protobuf-encoded, Zstd-compressed WAL cuts Safekeeper-to-Pageserver bandwidth by about 70%. Sparse files via ftruncate and fewer fsyncs give about 3.3x WAL write throughput. Scan prefetching of up to 100 pages made schema finalization 4x faster, prioritizing L0 compaction with ingest backpressure halved p99 read amplification, pipelined parallel S3 uploads doubled upload rate, and a graduated shard split policy (4/8/16 shards at 16 GB/1 TB/2 TB) improves mid-size and very large tenants.

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

  • The Noisy Neighbor Problem in Multitenant Architectures

    Neon easyNovice

    Noisy neighbors in a shared Postgres instance such as AWS RDS degrade performance for every tenant through CPU saturation, work_mem and shared_buffers pressure, disk I/O contention on EBS, exhaustion of max_connections, and lock contention from long transactions. Within RDS, the mitigations range from per-tier statement_timeout values, PgBouncer connection quotas per tenant and application-level rate limiting, to schema-per-tenant throttling, up to full database-per-tenant isolation, which is costly and operationally heavy. Neon's pitch is a project per tenant: storage is shared while each tenant gets isolated compute that autoscales and scales to zero, which makes per-tenant isolation affordable.

  • Everyone gets faster writes: We turned off FPW's in Neon

    Neon hardMaster

    Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear. To keep delta chains bounded without FPW images, the pageserver now generates page images itself once a page accumulates more deltas than a threshold, rather than relying on the checkpoint cycle. HammerDB TPROC-C throughput rose up to 4.5x on 32 vCPU, and WAL per transaction fell from 58KB to under 4KB (94%). In production, p99 read latency dropped 30-50%, and the change was rolled out without restarts via the XLOG_FPW_CHANGE WAL record.

The quest for software engineering knowledge.

Look:
Layout: