[erlang-questions] eep: multiple patterns

Sean Hinde <>
Fri May 30 17:06:13 CEST 2008

On 30 May 2008, at 13:37, Ulf Wiger (TN/EAB) wrote:

> Per Melin skrev:
>> Erlang and the BEAM have been very good to me when it
>> comes to degrading gracefully under too much load, and
>> then returning to normal once the load decreases. But one
>> thing that has blown up my apps several times is the
>> performance characteristics of selective receive.
>> I'm not arguing against selective receive or "textbook
>> erlang state machines". On the contrary, I only wish I
>> could write them more often.
>> For most cases it's fine, but still, these days I think
>> long and hard before I put a process in the state of
>> "I'm going to ignore some messages while I finish
>> this task."
> The thing is, though, that since selective receive
> is difficult to modularize, and it has known
> performance problems if the message queue grows too
> large, programmers will have a tendency to avoid it
> even when it's absolutely necessary, in which case
> they invariably end up either maintaining an impossibly
> large state transition matrix, or implement selective
> receive themselves (which is guaranteed to have even
> worse characteristics than the built-in one.)

As I understand it, the problem of poor performance with large message  
queues is not specifically related to selective receive, but is  
related to garbage collection of a large queue however it grows.

Use of selective receive may or may not make it more likely that a  
queue will grow, that depends on the design of the application.

In my experience the biggest causes of unbounded queue growth are when  
one (or more) processes or external inputs overwhelm another process  
with messages in a heavily loaded system. Nothing to do with selective  
receive, more likely using {active true} on a socket or such like.


More information about the erlang-questions mailing list