A distributed Erlang system consists of a number of Erlang runtime systems communicating with each other. Each such runtime system is called a node. Message passing between processes at different nodes, as well as links and monitors, are transparent when pids are used. Registered names, however, are local to each node. This means that the node must be specified as well when sending messages, and so on, using registered names.
The distribution mechanism is implemented using TCP/IP sockets.
How to implement an alternative carrier is described in the
A node is an executing Erlang runtime system that has
been given a name, using the command-line flag
The format of the node name is an atom
Example:
% erl -name dilbert (dilbert@uab.ericsson.se)1> node(). 'dilbert@uab.ericsson.se' % erl -sname dilbert (dilbert@uab)1> node(). dilbert@uab
A node with a long node name cannot communicate with a node with a short node name.
The nodes in a distributed Erlang system are loosely connected.
The first time the name of another node is used, for example, if
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. This feature can be turned off by
using the command-line flag
If a node goes down, all connections to that node are removed.
Calling
The list of (visible) nodes currently connected to is returned by
The Erlang Port Mapper Daemon epmd is automatically
started at every host where an Erlang node is started. It is
responsible for mapping the symbolic node names to machine
addresses. See the
In a distributed Erlang system, it is sometimes useful to connect to a node without also connecting to all other nodes. An example is some kind of O&M functionality used to inspect the status of a system, without disturbing it. For this purpose, a hidden node can be used.
A hidden node is a node started with the command-line flag
This feature was added in Erlang 5.0/OTP R7.
A C node is a C program written to act as a hidden node
in a distributed Erlang system. The library Erl_Interface
contains functions for this purpose. For more information about
C nodes, see the
Authentication determines which nodes are allowed to communicate with each other. In a network of different Erlang nodes, it is built into the system at the lowest possible level. Each node has its own magic cookie, which is an Erlang atom.
When a node tries to connect to another node, the magic cookies are compared. If they do not match, the connected node rejects the connection.
At start-up, a node has a random atom assigned as its magic
cookie and the cookie of other nodes is assumed to be
Thus, groups of users with identical cookie files get Erlang nodes that can communicate freely and without interference from the magic cookie system. Users who want to run nodes on separate file systems must make certain that their cookie files are identical on the different file systems.
For a node
The default when a connection is established between two nodes,
is to immediately connect all other visible nodes as well. This
way, there is always a fully connected network. If there are
nodes with different cookies, this method can be inappropriate
and the command-line flag
The magic cookie of the local node is retrieved by calling
Some useful BIFs for distributed programming
(for more information, see the
Examples of command-line flags used for distributed programming
(for more information, see the
Examples of modules useful for distributed programming:
In the Kernel application:
In the STDLIB application: