sks

sks

Cluster erlang nodes without DNS and FQDN

I have create a Elixir Phoenix Project that is to be run on bare metal physical servers (one node per physical server) in a LAN setup.

I am using Elixir mainly for fault tolerance.

I am exporting my application using mix releases and running them on multiple nodes (1 node being 1 physical server)

I am trying to connect these nodes to each other using a custom UDP broadcast based setup, I tried using “libcluster” but it did not work out for me.

So what I am doing currently is broadcasting the nodename, from each node, to the UDP broadcast address 255.255.255.255 and then when other nodes receive the packet, they try to connect to each other.

However there are many issues that I am currently facing. I tried disabling EPMD and running the node on a static port (following many examples online, but that did not really solve my issue)

In my case, I don’t control the machine’s hostnames. The machines can all have the same hostname, and are thus by nature not resolvable by something like machine1.local or such. Also since this is just LAN, there is no DNS running, and this system is supposed to work without internet. That means this system is completely offline and not connected to the public internet.

Since i don’t control the machine’s hostnames, and in a cluster erlang nodes must have unique names. I am setting them up using this env.sh.eex file.

#!/bin/sh  
NODE="$(uuidgen)"
export RELEASE_DISTRIBUTION=name 
export RELEASE_COOKIE="static-cookie" 
export RELEASE_NODE="app@$NODE"

I am trying to set them to a unique name by providing a random hostname myself.
(I realize that this might not be a good solution)

From what I understand the erlang node names are not separate parts, they are a whole atom. So it is not really app@host, it is just a whole host name.

I have read up on several articles to come to the above conclusion.

SO here I am asking the community on what should I do to allow seamless automatic node connections in my setup.
NOTE: I want that whatever N number of machines are running with my elixir phoenix project on the local lan, should form a cluster, without DNS, FQDN or worrying about DHCP.

Since each node can also be connected to the LAN using multiple NICs (for fault tolerance), suffixing the node name with the IP address is not really a solution in my case, and also DHCP can make it change during restarts (such as if something goes wrong with one node)

So what are my options to make it auto connect, with the above restrictions.

I am open to any changes to my idea, but it would be better to depend less on the network, and more on the code, beacuse I am not in control of the network or the machine’s hostnames.

Thank you for reading the above.

Most Liked

joram

joram

I’m not an expert on this, but my understanding is that you need three things to make a connection:

  • Both sides need the same cookie
  • Both sides need to agree on the full name of the node being connected to, including the host part
  • The connecting side needs the part after the @ to resolve to the host the listening side is running on. That means it either needs to be an IP address, or it needs to be a working DNS name

If you can’t use IP addresses you need some kind of name resolution. One idea could be to generate a hostname (I believe it needs at least one dot) and have the receiving side of the broadcast put that into the local hosts file with the correct IP address before connecting.

You can also implement a custom EPMD module. The address_please/3 callback is the one doing DNS resolution.

junaid1460

junaid1460

Nice, didn’t know existed, I was suggesting how to build one if nothing out there. This is great.

Where Next?

Popular in Questions Top

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
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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 ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

We're in Beta

About us Mission Statement