DNSSRVCluster - Elixir clustering with DNS SRV records

After @chrismccord released GitHub - phoenixframework/dns_cluster: Simple DNS clustering for distributed Elixir nodes, I tried to use it but did not get on with it. Because Elixir/Erlang distribution by default works with FQDN names, and dns_cluster works with IPs. But I wanted simple DNS distribution with FQDN names. So, I’ve made a library that works with DNS SRV records (SRV record - Wikipedia).

With DNS SRV records you can add your nodes in FQDN format like this:

_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node1.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node2.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node3.yourdomain.com.
_app._tcp.yourdomain.com. 86400 IN SRV 0 10 1234 node4.yourdomain.com.

Installation is simple.

By default it works as an application, but you can use it as a part of your supervison tree too.

PS. To make your life easier with Elixir/Erlang distribution, I recommend you to use Nbpm as it removes any EPMD headache you might have.

7 Likes