FreeBSD TCP Performance Tuning

Posted on in system_administration

cover image for article

To enable RFC 1323 Window Scaling and increase the TCP window size to 1 MB on FreeBSD, add the following lines to /etc/sysctl.conf and reboot.

net.inet.tcp.rfc1323=1  
kern.ipc.maxsockbuf=16777216  
net.inet.tcp.sendspace=1048576  
net.inet.tcp.recvspace=1048576

You can make these changes on the fly via the sysctl command.

sysctl net.inet.tcp.rfc1323=1
sysctl kern.ipc.maxsockbuf=16777216
sysctl net.inet.tcp.sendspace=1048576
sysctl net.inet.tcp.recvspace=1048576

In addition, FreeBSD may have a low number of network memory buffers (mbufs) by default. You can view the current mbuf configuration by running netstat -m. If your mbuf value is too low, it may cause your system to become unresponsive to the network. Increase the number of mbufs by adding the line below to /boot/ loader.conf and rebooting.

kern.ipc.nmbclusters="16384"

Note: a reboot is required to increase the number of mbufs.

Part 7 of the TCP Performance Tuning series

Slaptijack's Koding Kraken