Increase OS UDP Buffers to Improve Performance
Linux places very restrictive limits on the performance of UDP protocols by limiting the size of the UDP traffic that is allowed to buffer on the receive socket. It is highly recommended that you increase these OS limits to at least 25MB before trying to run UDP traffic to your server. 25MB is just a recommendation.
Linux
Check the current UDP/IP receive buffer default and limit by typing the following commands:
$ sysctl net.core.rmem_max
net.core.rmem_max = 212992
$ sysctl net.core.rmem_default
net.core.rmem_default = 212992If the values are less than 26214400 bytes (25MB) you should add the following lines to the /etc/sysctl.conf file:
net.core.rmem_max=26214400
net.core.rmem_default=26214400Changes to /etc/sysctl.conf do not take effect until reboot. To update the values immediately, type the following commands as root:
$ sudo sysctl -w net.core.rmem_max=26214400
net.core.rmem_max = 26214400
$ sudo sysctl -w net.core.rmem_default=26214400
net.core.rmem_default = 26214400BSD/Darwin
On BSD/Darwin systems you need to add about a 15% padding to the kernel limit socket buffer. Meaning if you want an 25MB buffer (8388608 bytes) you need to set the kernel limit to 26214400*1.15 = 30146560. This is not documented anywhere but happens in the kernel here.
Check the current UDP/IP buffer limit by typing the following command:
$ sysctl kern.ipc.maxsockbufIf the value is less than 30146560 bytes you should add the following lines to the /etc/sysctl.conf file (create it if necessary):
kern.ipc.maxsockbuf=30146560Changes to /etc/sysctl.conf do not take effect until reboot. To update the values immediately, type the following commands as root:
$ sudo sysctl -w kern.ipc.maxsockbuf=30146560