Skip to content

How it works

Peat is Neon’s storage engine, run for you by a Kubernetes operator. You describe the whole install in one object, a Platform, and each database in another, a Database. The operator makes everything else and keeps it as you declared it.

An ordinary Postgres keeps its data on the disk of the machine it runs on. In Peat the two are apart:

  • A compute is a Postgres process with no data of its own. It is a pod, started when a client connects and removed when nobody uses the database.
  • The storage keeps every database’s data and its whole history of changes, and serves pages of it to whichever compute asks.

A compute keeps a local cache of the pages it has read (1 GiB by default, the Platform’s computes.cache), so reading them again does not go back to the storage. The cache is empty after a wake and fills as the database is used.

That split is where Peat’s features come from. A database with no compute costs no memory or CPU, so it can sleep. A branch is a new compute reading the same stored history from a chosen point, so it copies nothing. A restore to a moment is the same thing at an earlier point.

PieceWhat it doesHow many
SafekeepersTake each write from a compute and keep it durable. A write is acknowledged once two of three hold it.3
PageserversTurn the stream of writes into pages, serve them to computes, and upload everything to your bucket.2
Storage controllerDecides which pageserver serves which database, and moves them when one is drained or lost.1
GatewaysThe front door. A client connects to a database’s name; the gateway wakes it if it sleeps and passes the connection through.2
Control layerTurns “a database” into storage and a compute, starts and stops computes, replaces what is lost.2, one acting
OperatorReads the Platform and makes all of the above. Runs upgrades one piece at a time.1

Your bucket holds the lasting copy of every database. The machines’ local directories hold what is recent and what is being served.

Every write must reach two of the three safekeepers before the client is told it is safe, and each safekeeper is on a machine of its own. Lose one machine and two safekeepers still agree, so writes go on. With two machines, losing one would stop every write.

The other pieces follow the same thinking: the two pageservers are on different machines, and the storage controller is never on a pageserver’s machine. Three machines is the fewest that fits all of it. The Platform’s status says in words what your install survives.

These are Kubernetes nodes. Three virtual machines on one physical box pass the rule and survive one virtual machine failing, but not the box.

A one-machine trial (spread: none) runs everything on one node. It works fully, and its status says it survives no machine’s loss.

NamespaceWhat is in it
peatThe storage pieces and the control layer
peat-computeThe databases’ computes, one pod each while awake
peat-gatewayThe gateways and the front door, the Service pg-front
peat-dbA name inside the cluster for each database

Your Database objects go in your own namespaces, beside the applications that use them. Each gets its login Secret there.

The storage engine and the compute are Neon’s open-source code, kept current on Postgres 18 and 19. What Peat adds is the part that runs it on your own cluster: the operator, the control layer, the gateways and the peat command. FORK.md lists every change made to Neon’s code.