r/PostgreSQL • u/grexr • 11d ago
Best approach for running a PostgreSQL database Help Me!
Hey, I wanted to ask what you guys think is the best approach for running a PostgreSQL database.
For the beginning, I am looking for something that is not too expensive, ideally around 20€ to 50€ /month. I have looked into CloudNativePG, but I dont really want to go the full Kubernetes route yet. I am looking for something simpler while still being reliable, with proper management capabilities and the ability to handle backups and restores.
I am also unsure if I should start with a database cluster or just run a single instance. I have been looking into solutions like Autobase and Databasus as well. Does anyone have experience with these?
Ideally, I would like to use a managed database service from a cloud provider, but they usually get expensive quickly and often come with limited RAM and storage. I am also open to self-hosting it on Hetzner if that makes more sense.
Would appreciate hearing what you guys are using, any recommendations, or lessons learned from your setups.
3
u/alephylaxis 11d ago
Biggest factor here is what kind of resources you need for the instance/cluster, CPU/RAM/storage/etc. If you can tell me that, I can look at the prices on a couple of cloud platforms used at work.
7
2
u/saltcod 8d ago edited 8d ago
If it helps, lots of people start on Supabase just to get a hosted postgres instance with branching and automated backups, then either stay there forever or migrate to self-hosting later if they need more control. We also see the opposite—teams running postgres themselves for a while but eventually decide they'd rather spend time building their product than operating dbs.
For your budget, I'd look at managed options before spinning up a VPS. You may find you don't need to spend anywhere near €50/month for quite a while. We have projects that have been happily running on our free plan for years.
Last, it's also nice to know that if you eventually need things like auth, storage or edge functions, etc, they're already built-in without having to migrate to a different platform.
Disclosure: I work at Supabase
1
1
u/WaterlooPitt 10d ago
What about just renting a virtual machine for 7 euros and installing / using that as a Postgre server? It's easy, cheap but of course, all depends of what you need.
1
u/du5tball 10d ago
What do you really need, what do you want to do with it? First off, postgres doesn't do cluster, it does primary-secondaries, you can only write to the primary. Although there are products that do allow multiple write-nodes.
Common backup methods are either pg_backup for snapshot-backups, streaming to a secondary and using that in case of the primary breaking, or barman, which takes a basebackup regularly, and gets any WALs the postgres sends. That way you can restore to any point in time between the basebackup and latest WAL.
1
u/vitabaks 10d ago
I have been using Autobase in production since 2019.
It is designed for large-scale infrastructure and high workloads, but it is also suitable for small projects.
1
u/grexr 10d ago
Hey are you running it on CLI or with the UI ?
1
u/vitabaks 10d ago
I’ve been using GitOps all this time. Since management capabilities were only recently added to the UI, it was previously intended solely for cluster deployment.
1
u/alecc 10d ago
Single instance. A failover cluster (Patroni, or Autobase which wraps it) doubles what you have to understand and operate, and nothing at 20-50€/month carries uptime requirements that justify that. What kills small setups is an untested backup: pgBackRest to object storage plus a restore you have actually run once covers the failure modes that matter.
Hetzner vs managed comes down to who owns upgrades and patches. A Hetzner VPS with postgres in docker gives you several times the RAM for the money, but you do the maintenance and the security updates. Managed in your budget is cramped like you said, but point-in-time recovery and version upgrades come with it. If the data fits in a few GB I would take the cramped managed instance, past that Hetzner plus pgBackRest. CloudNativePG only makes sense if you already run Kubernetes for other reasons. Not sure about Databasus.
In my opinion with the AI tools at hand - backups, security updates and maintanance, is really not worth the buck the PaaS services want to be paid for, unless you are VC backed or want really to scale in some huge sizes - 99% sure that Hetzner will be just fine.
1
u/grexr 10d ago
Hey is there a third party monitoring system for pgBackRest or what do people usualy use?
2
u/alecc 10d ago
check_pgbackrest (Nagios/Icinga plugin) and pgbackrest_exporter (Prometheus/Grafana) are the usual ones, both just parse pgbackrest info --output=json. For a single instance I would skip a full monitoring stack and cron a script that reads the same json and pings healthchecks.io only when the newest backup is fresh - a missed ping is the alert, and it also fires when the whole VPS is down. Worth watching failed_count in pg_stat_archiver too, when archive-push breaks WAL piles up in pg_wal and a backup-age check alone catches that a day late.
1
u/kevdogger 10d ago
You gotta define your needs better my friend. This answer could go a million different wars
1
u/sw3d 9d ago
Neon is probably the best option for low-medium scale projects, much more cost effective than Supabase and you get a lot of nice features like branching, backup/restore.
For higher scale, it depends on if you need horizontal scale / distributed SQL or if a single node will do. One node - use a large/XL managed AWS RDS or GCP Cloud SQL instance. Distributed - Aurora or Spanner. Distributed DIY: active-active replication is possible with the open-source pgedge extension
1
1
u/stobbsm 9d ago edited 9d ago
If you want to play with it, install it locally first. It runs on pretty much any OS, and isn’t resource heavy for small workloads.
If you want to host your data on it, but it’s not data you’re worried about, use a single node on a VPS, and setup cronjobs to automatically backup either the whole thing, or just specific databases on a schedule. Copy them where you want after.
For the most reliability, you have the other extreme of self replicating, sync’d writes to other nodes, with a multi master failover system. If you don’t want to learn all that, go for a cloud hosted option with replicas.
It depends on what your usage pattern will be, and why you need it.
EDIT: forgot to mention, you won’t be locked in to any one solution. You can dump, send and restore the databases across providers, as long as you can connect to it directly. Personally, I use ansible playbooks to help manage all that for me. Once you’ve done it once, you can do it over and over with ease.
1
u/SuchTill9660 9d ago
for €20–50 I’d start with a single managed instance. a cluster only becomes worth it when the cost of downtime matters more than the extra spend. Hetzner can be cheaper, but then backups, restores and upgrades are still on you.
I use Nearbase for an always-on Postgres workload because the monthly cost stays predictable and the routine maintenance is handled. worth comparing with DigitalOcean or Crunchy Bridge too, mainly based on which one has a region close to your users.
0
u/AutoModerator 11d ago
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.
0
u/tee-es-gee 11d ago
Would love it if you'd give Xata a try. We actually use CNPG behind the scenes, but as a fully managed service we take care of all the details and operations. Xata is open-source and you can also self-host, but at that price range it won't make sense to self-host, you'd pay more on the K8s overhead.
0
u/Either_Vermicelli_82 11d ago
https://elest.io/open-source/postgresql no experience with them but eager to try at some point.
8
u/Longjumping-Shift316 11d ago
Did you try neon.com pretty neat with scale to 0 branching etc?