How to scale my app horizontally

I come from a background in IoT and backend work.
Mostly, I got around doing NodeJS, C++ and Python wherever possible.
I just got my hands on learning Elixir + Phoenix ! (yay)

I did a basic project with a small crud that updates some liveviews.

Basically, I used to deploy an MQTT broker, EMQX to pass messages around my backend services. What was cool with EMQX was the fact you could set up «broker forwarding».
Meaning, if you had many distributed brokers, if a client posts a message on TOPIC A on broker 1, other subscribers of TOPIC A on broker 2 would also receive the message.

My question is: if I had to deploy many instances of my app on 2 computers,
would there be any way to replicate the EMQX forwarding behaviour?
If so what are the specific terms I should look and google for ?

You can look into “distributed erlang”.

First you need a fixed set of named elixir nodes that know about each other and are connected. You give them the list of all nodes names and make them connect at startup.

With a dynamic set of nodes you can also look into libcluster for node discoverability and keeping the herd together.

Then to dispatch a message from one place to all nodes you can use process groups, gproc or of course Phoenix.PubSub.

Or you can still use MQTT if you like!

1 Like