Menu

FreeBSD Tuning

January 14, 2025

This page contains information on tuning FreeBSD hosts connected at speeds of 10Gbps or higher.

Note: This information is quite old and likely out of date. If you are currently running FreeBSD and know what needs to be updated, please contact us. 

Basic tuning configuration

Here are the recommended settings for /etc/sysctl.conf. Some of these are the default settings, but are included in case someone changed the defaults on your system. 

# set to at least 64MB for 10G+ hosts
kern.ipc.maxsockbuf=67108864
# set autotuning maximum to at least 64MB too
net.inet.tcp.sendbuf_max=67108864
net.inet.tcp.recvbuf_max=67108864
# enable send/recv autotuning
net.inet.tcp.sendbuf_auto=1
net.inet.tcp.recvbuf_auto=1
# increase autotuning step size
net.inet.tcp.sendbuf_inc=16384
net.inet.tcp.recvbuf_inc=524288
# set this on test/measurement hosts
net.inet.tcp.hostcache.expire=1

Advanced congestion control in FreeBSD

FreeBSD supports TCP autotuning and advanced congestion control algorithms in all currently-supported releases. You can check which are available in the running kernel using:

  sysctl net.inet.tcp.cc.available

To make additional algorithms available in the kernel, the appropriate module must be loaded. The congestion control modules are in /boot/kernel and begin with cc_ - they can be listed with the following command:

  ls /boot/kernel/cc_* | grep -v symbols

To load a particular congestion control algorithm (for example htcp) you can use:

  kldload cc_htcp

and you will then be able to set the congestion control algorithm using this:

  sysctl net.inet.tcp.cc.algorithm=htcp

Other information

By default, FreeBSD caches connection details such as the slow start threshold and the congestion windows size from the previous connection to the same host for 1 hour. While this is a good idea for a web server, it makes it hard to do network throughput testing, as 1 large congestion event will throttle performance for the next hour. To reduce this effect, set hostcache.expire to 1.

More information on FreeBSD is available here.