Erlang distributed
- Distributed connection epmd
- Message transmission
Reference
Basics
Node connection process
Introduction to basic knowledge of node connection
Distributed related code guide
Node connection establishment process
Node process communication, after reconnection, the previous pid invalidation problem description
Message
Basic inter-process message transmission
Processing of large message transmission scenarios between nodes, using round-robin sending solution, business-unfriendly, not recommended
Principles of message sending
- Message transmission characteristics
Non-blocking, ordered, same-node use refc binary to process big data
Binary
- [Erlang20] Let’s conquer Binary
- Representation and implementation of Erlang data types (5) - binary
- Erlang: high memory usage for processing list of binary parts
Example
- Start
erl -name bb@127.0.0.1
erl -name aa@127.0.0.1
net_kernel:connect_node('bb@127.0.0.1').
- You can view the communication data between nodes
net_kernel:i().
Node State Type In Out Address
bb@127.0.0.1 up normal 728 549 127.0.0.1:52660
Total 728 549
ok
net_kernel:node_info('bb@127.0.0.1').
{ok,[{owner,<0.8287.0>},
{state,up},
{address,{net_address,{{127,0,0,1},52660},
"127.0.0.1",tcp,inet}},
{type,normal},
{in,721},
{out,544}]}
- sys_dist ets table stores the node information of the connection
ets:tab2list(sys_dist).
[{connection,'bb@127.0.0.1',
{1,#Ref<0.4062885077.249954305.136891>},
up,<0.8287.0>,#Port<0.14>,undefined,
{net_address,{{127,0,0,1},52660},"127.0.0.1",tcp,inet},
[],normal}]
- epmd names
epmd -names
epmd: up and running on port 4369 with data:
name bb at port 52660
name aa at port 52589
Others
- Get information through sys_dist to monitor the communication volume between nodes
- Get the port of the current node connecting to the target node
inet:port(#Port<0.14>).
{ok,52669}