[erlang-questions] Not an Erlang fan

Claes Wikstrom <>
Tue Sep 25 21:31:05 CEST 2007


David King wrote:
>> spawning cat is actually a very bad idea - It'll lead to all
>> kinds of havoc since ports don't by themselves have any means
>> to do flow control.
>> Spawning cat will lead to a situation where a whole lot of messages
>> will be sent to the owner of the port. When we do socket I/O this is
>> the equivalent of having {active ,true} on a socket, we'll just get
>> a lot of messages and if we cannot process the messages at the same
>> speed or higher than we receive them our message inbox will fill up
>> and we'll just be spending time in the garbage collector - bad.
> 
> Would it be enough to have one process that accepts all of these 
> incoming Port messages, adding them to a queue, and then making them 
> available to another process to request?


No,

> 
> In theory that should be able to keep up with the rate of messages as 
> long as it's receiving them more slowly or equal to the speed at which 
> it can add them to the queue, and allows them to come in line-by-line 
> (and be fetched line-by-line by the second process)
> 

We want to get to the built in flow control that is part of
the operating system. When the buffers are full, the writer blocks.
If we keep on reading and buffering the messages, the writer will never
block.

/klacke



More information about the erlang-questions mailing list