Skip to content

Instantly share code, notes, and snippets.

@Arp-G
Last active August 26, 2023 18:18
Show Gist options
  • Save Arp-G/51f35c54edc56caac151ef5ff6b1d330 to your computer and use it in GitHub Desktop.
Save Arp-G/51f35c54edc56caac151ef5ff6b1d330 to your computer and use it in GitHub Desktop.
Erlang's Distributed System Essentials
  • Erlang nodes communicate with each other using a custom communication protocol called the "Erlang Distribution Protocol”
  • EPMD: Erlang Port Mapper Daemon (EPMD) is typically installed by default alongside Erlang/OTP distribution on most Linux systems. It manages node registration and discovery in distributed Erlang systems. EPMD operates as a separate daemon process, listening on port 4369. The protocol is simple text-based and built on top of TCP/IP. The EPMD process can be started explicitly or automatically as a result of the Erlang node startup(The daemon is started automatically by command erl).

    EPMD acts as a name server on all hosts involved in distributed Erlang computations. When an Erlang node starts, the node has a name and it obtains an address from the host OS kernel. The name and address are sent to the epmd daemon running on the local host. The job of the epmd daemon is to keep track of which node name listens on which address. Hence, epmd maps symbolic node names to machine addresses.

    • Node Communication with EPMD: To communicate with a remote node, a querying node establishes a TCP/IP connection to the remote node's IP address and port number, where EPMD runs. After the connection is established, the querying node sends a textual command to request information about registered nodes on the remote node. The EPMD process on the remote node processes this request, responding with the requested information in a textual format. The querying node then uses this information to establish direct connections to the distributed communication ports of registered nodes on the remote node.
  • Authentication: Erlang nodes use a shared secret authentication cookie stored in the ~/.erlang.cookie file on each node's host system. This cookie is a string of characters that must match between connecting nodes. The cookies are never sent in cleartext instead md5 digests and challenges are used for authentication.

  • Dynamic Node Management: Adding or removing nodes dynamically doesn't require special configuration. New nodes can be started with unique names and connected to existing nodes using net_kernel:connect_node/1. To remove a node gracefully, check this. If a node crashes or becomes unreachable, the network eventually detects this and marks the node as disconnected. Connections are by default transitive.

  • Connections are by default transitive. If a node A connects to node B, and node B has a connection to node C, then node A also tries to connect to node C

Refs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment