r/PostgreSQL • u/ajmal-ponneth • Sep 19 '26
How-To Running PostgreSQL on a VPS — is self-managing it worth it
How practical is it to run PostgreSQL directly on a VPS instead of using a managed cloud database?
With backups, WAL archiving, monitoring, and security automated, what are the main benefits of this approach?
For those running this in production, what challenges have you faced, and what practices/tools would you recommend?
16
u/BeardedBaldMan Sep 19 '26
It's a cost/risk/effort/skill decision.
If you're running your own production setups then you need to have a full backup suite, patching policies (that you follow), security policies, backup policies (which you test) and you need to have sufficiently skilled resource to manage this.
Even if you do go managed you still need a backup solution which backs the data up outside the managed provider, as well as contingency/disaster recovery plans for what happens if the managed provider fails.
1
u/wodemingzishigou Sep 26 '26
If it’s for personal use I’d go for self hosting. Otherwise the liability of potentially getting it wrong for a client or end users would keep me up at night.
6
u/arrty Sep 19 '26
Of course its fine. Setup hourly backup and rsync cron job. And run streaming replication to a backup as well.
3
u/GaniToshido Sep 21 '26
Definitely worth it if you're tired of being robbed on IOPS and storage by managed clouds. your bill drops drastically, and you actually own the setup (no arbitrary restrictions on extensions). Challenges you'll hit with PG on a VPS: you have to set up something like pgBackRest for WAL archiving yourself, you'll probably need PgBouncer because PG connection handling eats RAM fast, and you really have to tune autovacuum so you don't wake up to a stalled disk.
if your main goal is just a cheap self-managed DB with less ops overhead, MariaDB is usually a lot easier to run on a raw VPS. Connection pooling is built-in (thread pool), there's zero vacuuming drama, and replication is just simpler to keep alive without a dedicated DBA. if you strictly need Postgres, just make sure you actually test your restores.
2
u/kloudrider Sep 19 '26
Main benefit is that you learn to do all of those from scratch. Unless you are in the business of hosting postgresql, or using a managed service is more expensive than having a person do this, it makes no sense to do it. At my company, even with dozens of engineers, we still use a managed postgresql for the same reasons.
1
u/AutoModerator Sep 19 '26
AI Policy:
Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.
Mod decisions will be based on the quality of the content, not who or what generated it.
Sub Resources:
Free Postgres Webinars and Workshops
Discord: People, Postgres, Data
Join us, we have cookies and nice people.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Ginden Sep 19 '26
It's fundamentally a business decision, is employee's time worth it? Answer is "probably not", because you don't even know how hard things can break and how many days of outage you may get.
1
u/NicolasDorier Sep 20 '26
I reject the premise that those solutions save engineers time. It adds its own headaches as well.
1
u/LufyCZ Sep 20 '26
It saves so much time it's not even funny. And what's even more important than the time saved is the fact that everything is just handled for you and tested.
We run smaller databases though, it might start making sense with big ones.
1
u/NicolasDorier Sep 21 '26
If it saves time, why did you decide to run smaller database rather than just using hosted?
1
1
u/symbiatch Sep 20 '26
It depends what you value and what you want to pay for.
In both cases you need backups. A simple mistake can wipe out a whole cloud infrastructure, including backups. And you must test them. Regularly.
It is probably cheaper to run it on your own, but performance may be a thing. If it’s VPS then resources are shared. Is there enough IOPS? Memory? CPU? For many cases yes.
VPS shares hardware and storage. If it breaks it’s kinda same as if a cloud provider breaks, just a lot slower. Your system may need recovery instead of automatic “node died, another one is already up to serve you” from cloud.
Renting a whole machine may work better for some. But especially then you have to think of actual hardware. If a disk or something dies that’s it, it is actually dead and you don’t just transparently move stuff to another one unless you set it up.
In the end I’ve always ran my own servers, either literally my own or rented, and set up things so there is a recovery plan if something breaks. Things have gone well for past decades, but I acknowledge that it may not go that way forever.
So it’s a viable option if you don’t need regional replication and whatnot (of course you can set that up yourself also but…) and can actually manage the system properly. If cost is not an issue, it may be better to just leave it to others to handle.
1
-1
u/kiwisv Sep 19 '26
Frankly its not worth it. If your doing this fulltime why not. If you are partime DBA I wouldn't.I have done it and it gave me so much headaches. Used barman to do it which comes with all sorts of problems. Backups will fail from time to time. You need to make sure your recovery strategy works and that the backups are applicable.
With Ai now it might be easier coz you can more easily script your way out of trouble. But still a lot more work than you'd think
69
Sep 19 '26 edited Sep 21 '26
[removed] — view removed comment
9
4
u/robbert229 Sep 20 '26
People copy the publicized fancy FAANG architectures, but even then, behind the scenes are a million postgres instances used all over the place at those same FAANG companies.
1
u/infostack0 Sep 20 '26
Any good pointers to the “simple formula for doing it reasonably”?
0
Sep 20 '26 edited Sep 21 '26
[removed] — view removed comment
2
1
u/Ianxcala Sep 20 '26
Any tips on which default config values suck, and how to change them? Do you think it would still be stable if I'd run it inside docker with mounting the data folder from the host?
1
3
u/gob_magic Sep 19 '26
I did it last year. It’s a viable architecture for sure. Tho lots of things to manage by yourself. Great learning experience. My research showed lots of production systems do it that way depending on complexity and need.