Top
Best
New

Posted by pavel_lishin 4 days ago

Go ahead, self-host Postgres(pierce.dev)
674 points | 396 commentspage 8
satvikpendem 4 days ago|
Better yet, self host Postgres on your own open source PaaS with Coolify, Dokploy, or Canine, and then you can also self host all your apps on your VPS too. I use Dokploy but I'm looking into Canine, and I know many have used Coolify with great success.
alexpadula 4 days ago||
Everyone and their mother wants to host Postgres for you!
PunchyHamster 3 days ago||
Cooking the RDS equivalent is reasonable amount of work, and pretty big amount of knowledge (easy to make failover solution have lower uptime than "just a single VM" if you don't get everything right)

... but you can do a lot with just "a single VM and robust backup". PostgreSQL restore is pretty fast, and if you automated deployment you can start with it in minutes, so if your service can survive 30 minutes of downtime once every 3 years while the DB reloads, "downgrading" to "a single cloud VM" or "a single VM on your own hardware" might not be a big deal.

yomismoaqui 4 days ago||
Now for the next step... just use SQLite (it's possible it will be enough for your case).

Disclaimer: there's no silver bullet, yadda yadda. But SQLite in WAL mode and backups using Litestream have worked perfectly for me.

irusensei 4 days ago||
And then there is the urge to Postgres everything.

I was disappointed alloy doesn't support timescaledb as a metrics endpoint. Considering switching to telegraf just because I can store the metrics on Postgres.

ErroneousBosh 4 days ago|
I've always just Postgressed everything. I used MySQL a bit in the PHP3 days, but eventually moved onto Postgres.

SQLite when prototyping, Postgres for production.

If you need to power a lawnmower and all you have is a 500bhp Scania V8, you may as well just do it.

WillDaSilva 4 days ago|||
It's pretty easy these days to spin up a local Postgres container. Might as well use it for prototyping too, and save yourself the hassle of switching later.
tcdent 4 days ago||
It might seem minor, but the little things add up. Make your dev environment mirror prod from the start will save you a bunch of headaches. Then, when you're ready to deploy, there is nothing to change.

Even better, stage to a production-like environment early, and then deploy day can be as simple as a DNS record change.

OccamsMirror 4 days ago||
Thanks to LetsEncrypt DNS-01, you can absolutely spin up a production-like environment with SSL and everything. It's definitely worth doing.
solarengineer 4 days ago||||
Have you given thought to why you prototype with SQLite?

I have switched to using postgres even for prototyping once I prepared some shell scripts for various setup. With hibernate (java) or knex (Javascript/NodeJS) and with unit tests (Test Driven Development approach) for code, I feel I have reduced the friction of using postgres from the beginning.

ErroneousBosh 4 days ago||
Because when I get tired of reconstructing the contents of the database between my various dev machines (at home, at work, on a remote server, on my laptop) I can just scp the sqlite db across.

Because it's "low effort" to just fire it into sqlite and if I have to do ridiculous things to the schema as I footer around working out exactly what I want the database to do.

I don't want to use nodejs if I can possibly avoid it and you literally could not pay me to even look at Java, there isn't enough money in the world.

solarengineer 4 days ago||
I mentioned Hibernate and knex as examples of DB schema version control tools.

Incidentally, you can rsync postgres dumps as well. That's what I do when testing and when sharing test data with team mates. At times, I decide to pgload the database dump into a different target system.

My reason for sharing: I accepted that I was being lethargic about using postgres, so I just automated certain things as I went along.

nileshtrivedi 4 days ago|||
I have now switched to pglite for prototyping, because it lets me use all the postgres features.
ErroneousBosh 4 days ago||
Oho, what is this pglite that I have never heard of? I already like the sound of it.
ishandotpage 4 days ago||
`pglite` is a WASM version of postgres. I use it in one of my side projects for providing a postgres DB running in the user's browser.

For most purposes, it works perfectly fine, but with two main caveats:

1. It is single user, single connection (i.e. no MVCC) 2. It doesn't support all postgres extensions (particularly postGIS), though it does support pgvector

https://github.com/supabase-community/pg-gateway is something that may be used to use pglite for prototyping I guess, but I haven't used this.

anonu 3 days ago||
does self-hosting on EC2 instance count?
notaseojh 4 days ago||
Another thread where I can't determine whether the "it's easy" suggestions are from people who are clueless or expert.
Nextgrid 4 days ago|
Ironically you need a bit of both. You need to be expert enough to make it work, but not "too" expert to be stuck in your ways and/or influenced by all the fear-mongering.

An expert will give you thousands of theoretical reasons why self-hosting the DB is a bad idea.

An "expert" will host it, enjoy the cost savings and deal with the once-a-year occurrence of the theoretical risk (if it ever occurs).

sapphirebreeze 4 days ago||
[dead]
darksaints 4 days ago||
honestly at this point I'm actually surprised that there aren't specialized linux distributions for hosting postgres. There's so many kernel-level and file-system level optimizations that can be done that significantly impact performance, and the ability to pare down all of the unneeded stuff in most distributions would make for a pretty compact and highly optimized image.
odie5533 4 days ago|
Recommends hosting postgres yourself. Doesn't recommend a distribution stack. If you try this at a startup to save $50 a month, you will never recoup the time you wasted setting it up. We pay dedicated managed services for these things so we can make products on top of them.
ijustlovemath 4 days ago||
There's not much to recommend; just use the Postgres from your distribution's LTS repo. I like Debian for its rock solid stability.
notaseojh 4 days ago|||
"just use postgres from your distro" is *wildly* underselling the amount of work that it takes to go from apt install postgres to having a production ready setup (backups, replica, pooling, etc). Granted, if it's a tiny database just pg-dumping might be enough, but for many that isn't going to be enough.
true_religion 3 days ago|||
If you're a 'startup', you'll never need any of that work until you make it big. 99% of startups do not make it even medium size.

If you're a small business, you almost never need replicas or pooling. Postgres is insanely capable on modern hardware, and is probably the fastest part of your application if your application is written in a slower dynamic language like Python.

I once worked with a company that scaled up to 30M revenue annually, and never once needed more than a single dedicated server for postgres.

dvtkrlbs 4 days ago|||
I don't think any of these would take more than a week to setup. Assuming you create a nice runbook with every step it would not be horrible to maintain as well. Barman for backups and unless you need multi-master you can use the builtin publication and subscription. Though with scale things can complicated really fast but most of the time you won't that much traffic to have something complicated.
marcosdumay 4 days ago||||
The one problem with using your distro's Postgres is that your upgrade routine will be dictated by a 3rd party.

And Postgres upgrades are not transparent. So you'll have a 1 or 2 hours task, every 6 to 18 months that you have only a small amount of control over when it happens. This is ok for a lot of people, and completely unthinkable for some other people.

true_religion 3 days ago||
Why would your distro dictate the upgrade routine? Unless the distro stops supporting an older version of Postgres, you can continue using it. Most companies I know of wouldn't dare do an upgrade of an existing production database for at least 5 years, and when it does happen... downtime is acceptable.
odie5533 4 days ago|||
Patroni, Pigsty, Crunchy, CloudNativePG, Zalando, ...
ezekg 4 days ago||
Maybe come back when your database spend is two or three orders of magnitude higher? It gets expensive pretty fast in my experience.