<div>From <a href="http://learnyousomeerlang.com/distribunomicon">http://learnyousomeerlang.com/distribunomicon</a>:</div><div><br></div><div><br></div><div><p style="margin:0px 0px 1.4em;padding:0px 50px 0px 0px;border:0px;outline:0px;font-size:0.8em;vertical-align:baseline;background-color:rgb(255,255,255);font-family:verdana,'trebuchet ms',helvetica,arial,sans;color:rgb(86,86,86);line-height:1.4em">
If, for some reason, you need to be sending large messages, be extremely careful. The way Erlang distribution and communication works over many nodes is especially sensitive to large messages. If two nodes are connected together, all their communications will tend to happen over a single TCP connection. Because we generally want to maintain message ordering between two processes (even across the network), messages will be sent sequentially over the connection. That means that if you have one very large message, you might be blocking the channel for all the other messages.</p>
<p style="margin:0px 0px 1.4em;padding:0px 50px 0px 0px;border:0px;outline:0px;font-size:0.8em;vertical-align:baseline;background-color:rgb(255,255,255);font-family:verdana,'trebuchet ms',helvetica,arial,sans;color:rgb(86,86,86);line-height:1.4em">
Worse than that, Erlang knows whether nodes are alive or not by sending a thing called<em style="margin:0px;padding:0px;border:0px;outline:0px;font-size:13px;vertical-align:baseline;background-color:transparent;background-repeat:initial initial">heartbeats</em>. Heartbeats are small messages sent at a regular interval between two nodes basically saying "I'm still alive, keep on keepin' on!". They're like our Zombie survivors routinely pinging each other with messages; "Bill, are you there?" And if Bill never replies, then you might assume he's dead (our out of batteries) and he won't get your future communications. Anyway, heartbeats are sent over the same channel as regular messages.</p>
<p style="margin:0px 0px 1.4em;padding:0px 50px 0px 0px;border:0px;outline:0px;font-size:0.8em;vertical-align:baseline;background-color:rgb(255,255,255);font-family:verdana,'trebuchet ms',helvetica,arial,sans;color:rgb(86,86,86);line-height:1.4em">
The problem is that a large message can thus hold heartbeats back. Too many large messages keeping heartbeats at bay for too long and either of the nodes will eventually assume the other is unresponsive and disconnect from each other. That's bad. In any case, the good Erlang design lesson to keep this from happening is to keep your messages small. Everything will be better that way.</p>
<p style="margin:0px 0px 1.4em;padding:0px 50px 0px 0px;border:0px;outline:0px;font-size:0.8em;vertical-align:baseline;background-color:rgb(255,255,255);font-family:verdana,'trebuchet ms',helvetica,arial,sans;color:rgb(86,86,86);line-height:1.4em">
<span style="color:rgb(0,0,0);font-family:arial;font-size:small;line-height:normal">Does someone have some code to reproduce this? I'm currently unable to.</span></p><p style="margin:0px 0px 1.4em;padding:0px 50px 0px 0px;border:0px;outline:0px;vertical-align:baseline;background-color:rgb(255,255,255)">
r.</p></div>