What I am attempting to do is ingest a lot of logs over UDP using nodejs. I ended up writing a decent bit of code to handle all of this. However, it appears I am losing a lot of the messages being sent over UDP when I am testing.
The simple code below will illustrate my problems:
var dgram = require("dgram")
, udp = dgram.createSocket('udp4')
, connections = 0
udp.on('message', function(msg){
connections++
})
setInterval(function(){
console.log(connections + ' msg per sec incoming')
connections = 0
},1000);
udp.bind(514)
All I do here is create socket and bind to 514. I use loggen (log generating tool on linux) to send 5k logs per second and my console looks like this:
2404 msg per sec incoming
2409 msg per sec incoming
2001 msg per sec incoming
2409 msg per sec incoming
2696 msg per sec incoming
2650 msg per sec incoming
However, then I increase the logs per second sent by loggen to 70k and my console looks like this:
30738 msg per sec incoming
32284 msg per sec incoming
35104 msg per sec incoming
34998 msg per sec incoming
34441 msg per sec incoming
33890 msg per sec incoming
I honestly have tried to figure out if this is a nodejs limitation or a UDP limitation or a NIC limitation, but really it doesn't seem like it is any of them. If Node can receive 30k+ messages per second at one point (despite it's lose of over 50%) why cant it receive 100% of the 5k sent previously? Regardless of the amount of messages sent it seems to be losing just over 50% of the messages.
Anyone have any suggestions as to what might be going on here? Obviously this is a very simple example but I see the same issues in my full code so the principles should probably be the same.