Elixir, Phoenix Multiple App clustering

Hi Flyio team!

So I have one Phoenix application currently deployed on Fly.io. It uses Broadway to process SQS messages that process images (high CPU utilization activities). Locally it had been working fine, but I hadn’t been testing with high res images which is what has caused me to re-evaluate my architecture.

My plan is to remove the broadway piece into its own elixir app. Is it at all possible using libcluster and DNSPoll to connect this different application to the application it was extracted from? I see the docs from both libcluster and flyio and am unsure if this will work.

Thanks in advance.

Hi Patrick,

This isn’t a direct answer, but more of a reference for a similar use case as yours.
In short, it suggests using a single app and controlling what workload each Elixir node is allowed to run.

And a conversation on clustered deployments, specifically, this post in it.

Additionally, if you stick with a single Fly app, and instruct the Elixir node what type of work it has to do with a start-up arg, you can make use of these:


… which is great because you can scale each layer separately.
As a bonus, you can also pick a beefier VM for the crunch layer.

In addition to what FrequentFlyer said, you can use libcluster to connect any arbitrary elixir node as long as the nodes can talk to each other. On fly, all instances in your organization share the same internal network, so you can drop libcluster in (or a couple libcluster configuration) into your apps and they will discover one-another via DNS like usual. Then you can send messages, do PubSub, or whatever is needed :slight_smile:

This is what I was hoping for!

This is my first distributed elixir app and first time needing to connect separate apps via this mechanism.

Thank you so much @FrequentFlyer and @chrismccord . I will give this a whirl and mark as solution as soon as I get it running. Happy Monday!

Here’s a handy table for app discovery in case you go the 2-app route.

In short, <appname>.internal gives you an A record of app instances.
_apps.internal gives you a TXT record of all apps in your org.
You can then parse it in your code to pick out the 2 apps and pass that to the DNSPoll bit.
I read in the doco that DNSPoll works with just A records, so the above bit may be needed if you go the 2-app route.