UDP Server Study Part 2 - NodeJs
In Part One of this series we tested a .NET (Mono) Udp Server.
The test has changed a little, and I’ll have to go back and update part one with the new results. The first test we ran was pretty simple. A client running on my machine at home sent 1000 udp packets to an Ubuntu instance running in AWS.
I decided that wasnt enough….. So now the client will generate and send as many packets as it can in a 30 second time frame. The client and the server will both display the number of packets they interact with and I do some fancy math to report on a percentage of success (received / sent).
The NodeJs server performed very similar to the Mono server, with around ~95% success rate.
The node server, and the entire project can be downloaded from here
Just like with the Mono example here is a Youtube video of the test, this time, with music.
Ok since writing this just a couple hours ago, I’ve been doing some research into how I can increase the performance even more. It seems that the packets that weren’t getting accounted for in the Node app were simply never making it there. Node just wasnt reading from the buffer fast enough and it was causing errors and packets to be dropped.
I made the following sysctl changes and have increased the efficiency of the app to 99.8% success rate
**
net.core.rmem_default = 8388608
net.core.rmem_max = 83886080
net.ipv4.tcp_rmem = 4096 87380 6291456
net.ipv4.udp_rmem_min = 4194304
root@ip:~# sysctl -w net.core.rmem_max=83886080
net.core.rmem_max = 83886080
root@ip:~# sysctl -w net.core.rmem_default=8388608
net.core.rmem_default = 8388608
root@ip:~# sysctl -w net.ipv4.udp_rmem_min=4194304
**