[erlang-questions] large messages - from LearnYouSomeErlang

Roberto Ostinelli roberto@REDACTED
Wed Oct 24 07:09:17 CEST 2012


>From http://learnyousomeerlang.com/distribunomicon:


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.

Worse than that, Erlang knows whether nodes are alive or not by sending a
thing called*heartbeats*. 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.

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.

Does someone have some code to reproduce this? I'm currently unable to.

r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121023/abb6e29d/attachment.htm>


More information about the erlang-questions mailing list