ariandanim

ariandanim

How to make connection between 2 VPS (1 VPS for Phoenix App & 1 VPS for Postgresql

Dear all,
I have purchase 2 VPS with different VPS Provider, 1 for Digital Ocean & 1 for Vultr, Please help me how to make connection between 2 VPS, 1 VPS for Phoenix App & 1 VPS for Postgresql ?

Most Liked

dogweather

dogweather

Conventional approach is to have both the master db and app servers at the same Provider and same datacenter. (I.e., super-fast & reliable networking) Then, for extra redundancy, have follower db’s at other providers.

So that’s two VM’s, one provider, one datacenter as the first start. But TBH, if your app is an initial proof of concept and/or not bringing in real traffic and money, you can easily run both on one VM, and get pretty far with that.

At Linode, my db is a managed cluster of 3 VM’s, but it presents itself as a single always-available db. Then, my apps are on the second VM that’s a dedicated-CPU with containers that I manage with Dokku. All the network traffic between the apps and the db is on Linode’s private network, and it’s unmetered. Linode has a nice free Firewall app that I’ve configured. Both VM’s get auto-backups by Linode. Total cost = $100/month.

I haven’t yet found the need for more redundancy.

Finally, though, I’m always trying out new hosting ideas in the background. I’m extremely impressed with fly.io and I’m working on that atm.

tj0

tj0

So there are two ways to do this

  1. Make your postgresql run on a public ip and setup ssl, etc. to ensure it is communicated securely.
  2. Setup wireguard as a private vpn between two hosts.

I would recommend that you just run them both on the same machine to be honest. I do believe that running wireguard is probably the better option if you don’t want to use the same machine.

mindok

mindok

I’m not sure that separating the app from the db will help you avoid a disaster. I think it will make it worse. With this approach you have more possible points of failure (if either DO or Vultr go down, or the connectivity between them goes down, your application will be broken). In addition, it is more complicated to manage and you will have a larger attack surface for hackers as you need to expose Postgres to the internet (or correctly implement a VPN without leaking details).

As @dogweather says, you are better off regularly copying/replicating the db off your main provider onto a secondary provider. If you have the code for the application, having the ability to restore the database onto new infrastructure is the most important thing for basic disaster recovery. You will also need to understand how to deploy the application onto that new infrastructure, update DNS records etc, but there’s no way to reconstruct the system if you lose the database.

Where Next?

Popular in Questions Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New

Other popular topics Top

New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement