The architecture of Neki
Neki shards unmodified PostgreSQL behind a single connection string. A Router speaks the Postgres wire protocol, parses and plans queries against the sharding layout, and either pushes joins down to shards or runs cross-shard nested-loop, hash or merge joins itself. Each instance runs a Sidecar that pools connections by lifetime (statement, transaction, session advisory lock) and a PostgresManager. Admin handles failover, pg_rewind and per-shard sync/async/cross-zone durability, while an authoritative shard keeps custom type OIDs consistent and etcd holds the Data Topology. A Replicator built on logical replication drives MoveTables, Reshard and shadow-table OnlineDDL, and the Router buffers retryable queries during cutovers and failovers.
Related posts
- Building a faster, lazier router for Postgres
PlanetScale hardMasterNeki, PlanetScale's Postgres sharding router, cuts per-query overhead by keeping PostgreSQL wire-protocol bytes intact and decoding only as much as each query requires. Results pass through as a raw byte slice and are only opened further when needed. They become row views for LIMIT, pointer slices for reordering and merge-sorting, and decoded, cached sort keys only for the columns being compared. Bind parameters and join keys are copied as length-prefixed frames, text and binary formats are preserved, and dropping columns copies contiguous runs of column frames instead of re-serializing values. Full decoding into typed values happens only when the router must compute new results, such as cross-shard aggregates. This contrasts with Vitess, which eagerly converts every row at RPC boundaries.
- 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.
- How we scale an open source, multi-tenant storage engine for Postgres written in Rust
Neon mediumAdept
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.
- Managed Postgres on Railway
Railway mediumAdeptRailway's managed Postgres now covers the full database lifecycle: private-by-default services with reference-variable credentials, usage-billed vertical scaling, live volume resizing, and one-click PgBouncer pooling with a separate unpooled URL for migrations. HA conversion turns an existing node into the primary of a Patroni-managed streaming-replica cluster with etcd for leader election and HAProxy for routing, so apps keep the same endpoint through failover but still need reconnect/retry logic. Point-in-time recovery uses pgBackRest with continuous WAL archiving (weekly full, daily differential, ~4 weeks retention) and restores into a separate service. Automatic image updates, CVE patching, guided pg_upgrade major upgrades with compatibility checks, pg_stat_statements-based query statistics, and CLI/MCP agent workflows round out the platform.
- 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.