Erlang / Erlang Advanced Interview questions
How does erlang:send/3 with the nosuspend option change message-sending behavior?
A plain Pid ! Msg send can, in rare cases, briefly suspend the sending process if the
underlying distribution buffer to a remote node is full — effectively creating unwanted back-pressure on
the sender. erlang:send(Pid, Msg, [nosuspend]) asks for the same send but refuses to suspend the
caller: if it would have had to block, it instead returns nosuspend immediately and the message is
not delivered.
case erlang:send(Pid, {event, Data}, [nosuspend]) of ok -> ok; nosuspend -> log_dropped_event(Data) end.
This is useful for genuinely best-effort traffic — metrics, non-critical notifications — where a sender would rather drop a message than risk stalling itself waiting on a slow or overloaded remote link. It's deliberately not the default, since silently dropping messages is the wrong tradeoff for anything the receiver actually needs to see.
More Related questions...