Distributed Elixir

Distributed Erlang is a fully-connected mesh; netsplits happen.

37.1 Nodes

--sname (short names) / --name (fully qualified: [email protected]).

The cookie authenticates nodes (~/.erlang.cookie). It's not encryption — use TLS distribution (-proto_dist inet_tls) over untrusted networks.

EPMD (Erlang Port Mapper Daemon, port 4369) maps node names to ports.

iex --sname alice --cookie secret
iex --sname bob --cookie secret
# on bob
Node.connect(:alice@hostname)     # true
Node.list()                       # [:alice@hostname]
Node.self()

Node.spawn(:alice@hostname, fn -> IO.puts("runs on alice") end)
send({:registered_name, :alice@hostname}, :msg)
:erpc.call(:alice@hostname, String, :upcase, ["hi"])
:rpc.multicall(Node.list(), Module, :fun, [])
Node.monitor(:alice@hostname, true)     # receive {:nodedown, node}

37.2 Global registration & process groups

:global.register_name(:leader, self())
:global.whereis_name(:leader)
GenServer.call({:global, :leader}, :ping)

:pg.start_link()
:pg.join(:workers, self())
:pg.get_members(:workers)

37.3 Clustering & distribution libraries

libcluster — automatic node discovery (Kubernetes, DNS, gossip, EPMD).

Horde — distributed Registry & DynamicSupervisor (CRDT-based).

Phoenix.PubSub — cluster-wide pub/sub.

Partisan — alternative distribution layer for large clusters.

FLAME — elastic scaling by running functions on temporary nodes.

37.4 CAP & caveats

Distributed Erlang is a fully-connected mesh; netsplits happen. Design for partitions (idempotent operations, CRDTs, external consensus like Raft via ra).