HACKER Q&A
📣 GordonS

Moving from Cloud to Self-Hosted


My business partner and I are building a bootstrapped B2B SaaS, and designed it from the start with the intention of running it on Azure (or AWS).

The use of Postgres and TimescaleDB is core to the product. But now we discover that Azure's managed Postgres is still stuck on an antiquated version of TimescaleDB, and we've also realised that our compute requirements are much greater than originally anticipated. Aside from the managed Postgres issue, it would cost too much to host at a cloud provider, so we're now considering self-hosting.

The components we need are fairly modest, but we need everything to be highly-available and backed up:

  - Postgres
  - Blob storage
  - Message queue
  - Compute
We're struggling with HA for Postgres in particular. I'm looking for advice and OSS solutions that would simplify and give more of a "semi-managed" feel, to help us deploy our own HA stack somewhere like Hetzner.


  👤 avivallssa Accepted Answer ✓
Interesting. Would try to answer in short but rather ask you go through this webinar video i have given sometime back.

https://www.percona.com/resources/webinars/enterprise-grade-...

Like some people mentioned - you could Patroni for HA. It is a template that could be configured with etcd like distributed consensus key value stores for leader election using the world famous RAFT algorithm. Could use Watchdog/Softdog for avoiding split-brain. Now, we could also do some actions before and after failover which can be scripted. Regarding HA on other pieces such as Blob store, you could use CRR using the AWS S3. You could just mount the S3 via NFS Gateway to DB servers and let the job be done in a more simpler way. Similarly, all the problems you mentioned are solved, however, anything you feel is still challenging after going through the webinar recording, please reply back here.


👤 verdverm
You could try Google Cloud and you may realize here are a lot more costs you haven't considered which make self hosting more expensive (maintenance and your time). Most SaaS and EE companies are running in the cloud, so why do you think cloud is cost prohibitive? What would happen if 200 people wanted to use your service tomorrow?

👤 ants_a
Patroni is a good choice for fully automated PostgreSQL HA. Depending on what you are comfortable with, you could either deploy it using something like Ansible on bare-metal or VMs, or with Spilo and postgres-operator on Kubernetes.

👤 tarun_anand
We use pg replication and Kafka for message queues - ie streaming data. An alternative is pulsar which has less management overhead.

Haven't found a good alternative to blob but consider minion