After watching @brainlid’s presentation I got inspired to try out this multiregion setup on Fly (for those who didn’t see it: ElixirConf 2021 - Mark Ericksen - Globally Distributed Elixir Apps on Fly.io - YouTube). However, I’m not able to set it up properly by just following the guides / readme’s - it keeps on failing to connect to the database. This is what I did:
I used the getting started guide, added libcluster and got the app running on in two regions:
This all seems to work fine. It also had setup a database cluster in a single region with that. After that I started with changing to code to support this multiregion db setup using the fly_postgres readme and implemented every step. Than I looked at the scaling the postgres cluster to multiple regions with this guide. Once the app was deployed with new code and
fly_postgres I added a new volume (so that I have 1 in ams and 1 in sea) and scaled the instances of the db cluster to multiple regions (but with max 1 for every region). This works and the
PRIMARY_REGION is set to ams for both the app cluster as the db cluster.
However, the sea app cluster can’t connect to the database:
Did anyone created a similar setup like this successfully? I’m not sure what I did wrong or what I can do to get it to work.