gen_udp:recv()

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed Apr 7 14:11:59 CEST 2021


On Mon, Apr 5, 2021 at 4:21 PM Avinash Dhumane <trigunatit@REDACTED> wrote:

> My need for the socket is {active, false}. I had tried with {active, true}
> in the past, and got the datagrams as individual messages in the inbox of
> my process. So, I assume that there will be one call to recv() per
> datagram. I do not have the setup to test {active, false}; hence, I am not
> sure about the behaviour of (and, rationale for) Length argument to recv().
>
>
It's due to being there in low level socket handling (in C). You need to
specify the size of the buffer to write the result into. It matters
somewhat. While Ethernet normally specifies a limit of 1500 bytes (minus
header, minus tagging, ...), a local loopback interface can easily be 16k,
64k, or more. And if you are considering a high count of receivers, it
might be wise to limit the maximal size you are willing to receive.

As for the overhead: if you have many small messages and need to have a
high processing rate, I'm going to suggest you either try {active, N} or go
the route Max laid out by moving the processing loop into C to get it fast
enough. You can work backwards: 100k messages per second means you have to
process messages at a rate of one per 10 microseconds. At those rates, it
isn't uncommon you need some kind of microbatching to keep up.


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210407/e16462f0/attachment.htm>


More information about the erlang-questions mailing list