[erlang-questions] Losing data
Jesper Louis Andersen
Thu Jun 2 21:20:52 CEST 2011
On Thu, Jun 2, 2011 at 21:09, Bob Cowdery <bob@REDACTED> wrote:
> The symptoms look like it just can't keep up but If a process was
> getting behind I would expect the message q to build up. CPU is 5-7%.
> Any ideas would be very welcome.
Ladies and Gentlemen! Welcome to the Circus of the Kernel! Tonight we
will have artist of all kinds: Jugglers! Trapezoids! Old Erlang
programmers. A balancing act with a VAX! And above all, there will be
Your problem is that you are sending data out too fast and the kernel
is then throwing your data away. This is especially true on Linux
where this happens silently. On FreeBSD I have seen ENOBUFS being sent
back when this happen, but Linux just choses to silently drop packets.
The only way to fix this is to pace packets so they are sent at a
slower rate - and build in a retransmit mechanism. It is the only way
to be sure. Note that the send buffer can be ridicously small on some
systems, so you can't rely on it. Though my code using UDP can surely
send around 8K on Linux without too much trouble.
Since the queue is tail-end dropping you see the problem where many
packets are lost suddenly. The queue fill up, and them you are in for
the surprise when the next 30 packets are just skipped and dropped.
There are a couple of fixes depending on what you want to do, but if
possible go check out SCTP which can give you many of the things you
want from UDP. It is kind of the hybrid between UDP and TCP and then
not. it is also a very interesting protocol - check it out!
More information about the erlang-questions