A node is one instance of the Erlang virtual machine running. If you're on linux and you list the processes, there will be one process for each node.
This means that when you start the vm on the terminal using erl, you are staring a new node every time.
If you're writing an application, you generally don't need to worry about the distributed portion of Erlang just yet. One node can handle millions of Erlang processes, and you can understand the model just fine by working on a single node. Processes and nodes are different concepts, so don't get them confused.
Nodes are isolated from each other, but Erlang has many facilities for communicating between them. You don't have to write any code to enable communication, it's a built in feature.
A simple demo of this can be done extremely simply:
- Open 2 terminals
- In terminal 1, start Erlang with a short name:
erl -sname hi
- In terminal 2, start Erlang with another name:
erl -sname hi2
The shell will show you what your nodes are now called:
Terminal 1:
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V7.1 (abort with ^G)
(hi@kwong-mbp)1>
Terminal 2:
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V7.1 (abort with ^G)
(hi2@kwong-mbp)1>
I can now get the nodes to ping each other:
(hi2@kwong-mbp)1> net_adm:ping('hi@kwong-mbp').
pong
If I list the nodes hi@kwong-mbp knows about, the other node will now show up:
(hi@kwong-mbp)1> nodes().
['hi2@kwong-mbp']
Erlang nodes use another daemon to figure out what Erlang nodes are running on a machine. When a node is looking for a node on another host, it asks the host machine's epmd instance for the information needed to connect.