[erlang-questions] How to handle a massive amount of UDP packets?

Ulf Wiger ulf@REDACTED
Sun Apr 22 23:30:05 CEST 2012


What one can do is to combine {active, once} with gen_tcp:recv().

Essentially, you will be served the first message, then read as many as you 
wish from the socket. When the socket is empty, you can again enable 
{active, once}.

BR,
Ulf W

On 22 Apr 2012, at 22:26, Valentin Nechayev wrote:

> Using {active,once} on socket type other than stream one principally can't
> give performance compared to uncontrolled stream, due to asynchronous manner
> of sending messages to owner's mailbox and its processing.
> OTOH, {active,once} is shorthand for "send me one next portion" and this "one"
> can be extended to more numbers; e.g. {active,100} for "send me 100 next
> packets and then stay and wait for next permit". This combines advantages
> of both modes ('once' and 'true').

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com






More information about the erlang-questions mailing list