Sorc96

Sorc96

Basic setup for distributed application using mix release

I haven’t been able to find a simple example for this. Let’s say we have a regular project with Phoenix that is deployed by building a mix release and copying that to a server.

Now if we want to run that application on two nodes, it is unclear what exactly needs to change I know it is necessary to set the RELEASE_DISTRIBUTION env var to name and set a unique RELEASE_NODE. The cookie should be the same, since it is set when the release is built.

But I’m wondering about the best way to actually connect the nodes when they are started. Also, is there anything else I’m missing?

Marked As Solved

D4no0

D4no0

The easiest way is to use libcluster for this, it does automatically a lot of things, like automatic connection, discovery etc.

Make sure to read about the available clustering strategies, the default one used by erlang is EPMD. Outside of EPMD, I’ve personally used in production Cluster.Strategy.Gossip with docker containers and it works out of the box.

Also Liked

joram

joram

The Phoenix generator, as of 1.7.8, includes dns_cluster. It’s a lot less featureful than libcluster, but if it does what you need it’s very convenient. With the minimal setup the Phoenix generator includes you only need to set the environment variable DNS_CLUSTER_QUERY to make it work.

Last Post!

Sorc96

Sorc96

That looks like it should be just enough for a simple use case. Thank you!

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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 44139 214
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement