Blog / Product

Cellar: serverless Postgres, in beta

One line in the manifest gives a stack its own Postgres database, served by Cellar. It sleeps when nobody uses it, wakes in about a second, and keeps its data in object storage. Here is how it works and what the beta does not promise yet.

Starting today, a stack can have its own Postgres database. It runs on Cellar, our new database engine: real Postgres under the hood, made serverless. Your app sees an ordinary Postgres server, and the database costs next to nothing while nobody uses it. Add one line to the manifest:

name: notes
addons: [postgres]
services:
  api:
    run: uvicorn main:app --host 0.0.0.0 --port $PORT

Every service in the stack gets a DATABASE_URL. The database stays with the stack through redeploys, expiry and claiming, and it is dropped when the stack is deleted. There is nothing to sign up for and no connection string to copy around.

It is in beta, and it is open to everyone. It is also now the way we recommend keeping an app's data, ahead of SQLite in $DATA_DIR. The rest of this post explains both of those, and what "beta" means here.

Why a database, and why now#

Until now, an app on AgentServe kept its data in $DATA_DIR: a directory per service that survives redeploys. Most agents put a SQLite file there, and for a single service that works well.

It stops working when a stack has two services that need the same data, say an API and a worker. Each service has its own directory, so they can't share a file. Agents worked around it by routing everything through one service, and the results looked like workarounds.

Agents also already know Postgres. Ask one for a backend and it reaches for Postgres and an ORM by default. Making it fall back to SQLite meant we were asking it to write code it would later have to rewrite. Now the default works on the first deploy.

What makes Cellar serverless#

Most stacks on AgentServe are small, short-lived and idle most of the time. A preview gets a few clicks and then sits for hours. Keeping a Postgres process running for each one would cost far more than the apps are worth, so the database follows the same pattern as the app:

  • It sleeps. When nothing has been connected for about a minute, Postgres is stopped.
  • It wakes on connect. The next connection starts it again, and the client just waits. On our test nodes, a database that was recently asleep answers its first query in 110 to 150 ms. One that has been fully closed takes about 0.8 seconds.
  • Its data lives in object storage. A database nobody uses costs its bytes in a bucket and nothing else: no process, no memory, no reserved disk.

The client sees an ordinary Postgres server, because that's what it is. Drivers, ORMs, psql and migration tools work unchanged, since every database is a real Postgres 18 process. Cellar only changes where its disk lives and when it runs.

How it works#

Cellar is named for what it does with your data: it keeps it cool in object storage and brings it up when someone asks. It borrows the two ideas that make Neon fast and leaves out most of the machinery behind them.

The first idea is that a commit never waits for the object store. When your app commits, the write is made durable on a replicated disk and acknowledged right away. It reaches the bucket later, in the background. Our first prototype skipped this step and sent every sync to object storage; commits took 190 ms. Now they take well under a millisecond.

The second idea is that waking a database means attaching to storage that is already running. Each node runs one volume daemon that serves every database's disk, with its connection to the bucket and its caches already warm. Waking a database doesn't open anything from scratch; it starts a Postgres on a volume that is already there.

Neon splits Postgres at the page level, which takes a Postgres fork and several services. We split one layer lower, at the block device, so Postgres sees a normal filesystem. Our only change to Postgres itself is a small patch to how it writes its log, which is where the commit times above come from. Underneath, the volume daemon (written in Rust, on top of SlateDB) stores 4 KiB blocks as keys in a log-structured tree in the bucket. Empty blocks cost nothing, so a 20 GB volume holding 50 MB costs 50 MB.

A small proxy in front reads the database's name from the TLS handshake, wakes the database if it's asleep, and then hands the connection over.

How fast it is#

We benchmarked a two-vCPU Cellar node against Neon at 2 compute units on the same day, alternating runs so neither side got a quieter network. The winner of each test is highlighted:

TestCellar, 2 vCPUNeon, 2 CU
Commit, one session (lower is better)0.60–0.65 msabout 0.65 ms
TPC-B, one session (higher is better)1,426–1,452 tps1,236–1,259 tps
2,000 cold scans (lower is better)79–83 s85–94 s
Bulk load, 600k rows (lower is better)2.33–2.84 s1.36–1.76 s

Cellar wins three of the four. Commits are faster by a hair, small transactions by about 15%, and cold reads by about 10%. Bulk loads are where we are still behind, and most of that gap is the throughput of the disk the write-ahead log goes to. For the apps agents build, which do many small writes and few huge ones, it's the trade we would pick.

We got there with software changes only. The node's size was fixed before we started, and we didn't buy our way to the numbers with a bigger machine.

What the beta does not promise#

We'd rather be plain about this, because it's your data:

  • There is no SLA. The beta runs on a single database node. If that node is down, so are the databases on it.
  • There are no backups beyond the node's own storage. The data is durable on replicated disks and in object storage, but we don't yet offer point-in-time restore or exports.
  • A beta database may be reset or moved. We'll give notice where we can.
  • The limits are small: one database per stack, 512 MB, 20 connections at once. Over the size limit, the database turns read-only until you free space. The full list is in Limits.

If the data matters, keep a copy somewhere else as well. The agent skill file tells agents to say so to their user when they add a database.

Try it#

The quickstart now uses it: the todo app keeps its todos in the stack's Postgres. If you are asking an agent to build something, you don't need to change anything. The skill file now tells it to add addons: [postgres] when the app has data to keep, and to fall back to SQLite only on a server without the add-on.

If you run your own AgentServe server, the add-on is off until you point it at a database node; the settings are in deploy/agentserve.env. Without one, a manifest that asks for Postgres is refused with a clear message.

The details are in Data. If something breaks, or a limit gets in your way, we want to hear about it: that's what the beta is for.

Shameless plug.

Point your agent at AgentServe. The next thing it builds gets a live URL, and you get the claim link.