
I got tired of paying $20 a month per database, so I put fifty of them on one $12 Lightsail box
Why managed Postgres pricing doesn't fit small client apps, and how one Lightsail instance, an S3 bucket and a bucket-scoped IAM user became a self-hosted alternative with restores you can actually trust.
Every client app we ship needs its own Postgres. A real app, real users, a couple of background workers and a database that sits near idle twenty-three hours a day. The managed plan for that database was $20 a month. Two hundred and forty a year, billed at production rates for a workload that never comes close to needing them.
That number wouldn't have bothered me if it were the only one. But I run a small agency, and I'm a student, and by then I was already paying for AI tools, a couple of VPSes, domains, and a growing pile of "just $20 a month" things. Every new client project came with its own little database bill. Five projects, five bills. The database had quietly become the most expensive part of shipping small software.
So I did what everyone does. I looked at the alternatives.
Dokploy spoiled me first. One-click self-hosting on my own VPS, and it even does scheduled database backups to S3. But every database gets its own container, its own Postgres process, its own memory. Which is the model I was trying to get away from. Ten projects, ten Postgres instances sitting mostly idle. Then I read the RDS docs properly and found the line that started all of this: you can run many databases inside one PostgreSQL instance. Great. Then it leaves you to create every role, every password, its backups are instance-wide, so recovering one project means restoring the entire instance somewhere else and dumping that one database out of it. Neon was the most interesting. It scales to zero, so an idle database is basically free. Except my apps aren't idle. Almost every one runs a worker every five or ten seconds, so the database never sleeps. On their pay-as-you-go plan the smallest always-on compute works out to about $19 a project. Back where I started.
What I actually wanted was boring: one server I own, a database per project in one click, and backups I don't have to think about but can trust. None of that existed in one place, so I kept meaning to build it and kept not building it. Then WeMakeDevs and AWS ran First Commit, and turning it into a competition made it fun enough to finally start. It's called Pgfy.
What it does
You run one command on an Ubuntu box. On a $12 Lightsail instance that takes about a minute: Docker, Postgres 18, Caddy, a Go binary with the dashboard built in, and a real Let's Encrypt certificate. Then you open the dashboard, type a name, and you get a database, a restricted role, and a strong password. Connections are TLS-only, and every project has an allowlist of IP addresses that gets written into Postgres's own
pg_hba.conf — the database refuses the connection itself, not some proxy in front of it.Backups go to an S3 bucket you own. Every day,
pg_dump runs per database, uploads the archive, and then publishes a small manifest with the table names, row counts and a SHA-256. The manifest goes last on purpose: if you see a manifest, the archive is complete.The part I'm proudest of is the restore. You install Pgfy on a fresh server, enter only the bucket credentials, and it lists every backup it can find. Pick one, and it restores into a new project — as a normal user, not a superuser — and then checks its own work: row counts against the manifest, that every table belongs to the new project's role, that the role can actually connect. If any of that fails, it tells you it failed. Most backup tools tell you the restore "succeeded" because
pg_restore exited zero. That is not the same thing.I added one more feature the day before the deadline, after realising I needed it for the demo: you can freeze writes on a project. The app keeps reading, every insert gets refused, you take a backup, and now you can move that database to its own server knowing nothing was written after the backup. It's about 150 lines of Go. Postgres already had everything I needed (
default_transaction_read_only on the role, then terminate its sessions); I just put a button on it.Where AWS fits
Lightsail for compute, S3 for backups, IAM for the credentials. That's the whole footprint. The IAM part matters more than it sounds: the dashboard lives on a $12 box, so it gets a user that can touch exactly one bucket and nothing else. Both demo servers are Lightsail, and I ended up doing all of the provisioning from the AWS CLI rather than the console —
create-instances , attach-static-ip , put-instance-public-ports , then the installer over SSH. Nothing to a verified install in about 110 seconds, repeatably, which is the only reason I could rehearse the recovery demo as many times as I did.Pgfy is not tied to AWS, and I don't think it should be. It's Ubuntu plus an S3 API. But Lightsail plus S3 plus IAM was the fastest path to a working, verified restore, and that's what I was optimising for.
Does it actually hold up?
I didn't want to guess, so I measured it on the real $12 instance — 2 vCPUs, 2 GB, a Xeon that AWS shares with other people. Fifty databases, about 1.9 GB of data, plus a hundred idle pooled connections (two per app, the way a real deployment would look): 508 MiB of memory. Ten of those databases hammered at once: about 1,400 mixed transactions a second. All fifty writing at the same time: about 1,250. A single database with twenty clients did nearly 16,000 simple reads a second.
Those aren't big numbers. They're also far more than fifty small client apps will ever ask for. The real limits are the ones you'd expect: hot data has to fit in roughly 1.3 GB of cache, the CPU is burstable, and there are 150 connections to share, so apps must pool. When one project outgrows the box, you freeze it, back it up, and restore it onto its own Pgfy box — $24 for 4 GB, $44 for 8 GB — in a few minutes. And if a project ever genuinely needs point-in-time recovery and automatic failover, the backup is a plain
pg_dump archive. I tested it: one pg_restore into RDS and it's there.For fifty low-traffic databases, one instance each on RDS is about $699 a month. You could rightly say: put them all in one instance and you can, about $26 for a db.t4g.small. Then you're back to creating fifty roles, fifty passwords and fifty allowlists by hand, and backing up all of them as one lump. That gap is the entire product. Pgfy on Lightsail plus S3 is about $14. I'm not pretending those are the same product. I'm saying that for the fifty databases nobody has time to babysit, the second one is the right product.
Something Hitesh Choudhary said at the First Commit meetup has stayed with me through all of this: not every app deserves a zero-downtime budget. Most of what I run can be down for a few minutes. What it can't be is unaffordable, and it can't lose data. Pgfy is built for exactly that trade.
The code is at github.com/c-varun14/Pgfy. It's a hackathon MVP with a production-shaped skeleton, and the README is honest about what isn't there yet project deletion, backup retention, alerts some of which we will work next :). If you run a pile of small databases and you're tired of paying for each one like it's production, try it on a $12 box and tell me what breaks.
And thank you to Dhanalakshmi D for agreeing to build this with me, and for the backend that everything else stands on: the store, the access-policy engine, and the jobs behind every backup and restore.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article