node.js UDP data lost at high package rates

Posted by koleto on Stack Overflow See other posts from Stack Overflow or by koleto
Published on 2012-07-02T08:55:59Z Indexed on 2012/07/02 9:15 UTC
Read the original article Hit count: 243

Filed under:
|
|

I am observing a significant data-lost on a UDP connection with node.js 0.6.18> and 0.8.0 . It appears at high packet rates about 1200 packet per second with frames about 1500 byte limit. Each data packages has a incrementing number so it easy to track the number of lost packages.

var server = dgram.createSocket("udp4");

server.on("message", function (message, rinfo) {

        //~processData(message);        
        //~ writeData(message, null, 5000);

}).bind(10001);

On the receiving callback I tested two cases I first saved 5000 packages in a file. The result ware no dropped packages. After I have included a data processing routine and got about 50% drop rate. What I expected was that the process data routine should be completely asynchronous and should not introduce dead time to the system, since it is a simple parser to process binary data in the package and to emits events to a further processing routine.

It seems that the parsing routine introduce dead time in which the event handler is unable to handle each packets.

At the low package rates (< 1200 packages/sec) there are no data lost observed! Is this a bug or I am doing something wrong?

© Stack Overflow or respective owner

Related posts about node.js

Related posts about udp