FreeBSD Tuning

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

FreeBSD added TCP autotuning in version 7.0, and better congestion control algorithms (cubic and HTCP) in version 8.2.

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. Explanations are below.

   # set to at least 16MB for 10GE hosts
# set autotuning maximum to at least 16MB too
# enable send/recv autotuning
# increase autotuning step size
# turn off inflight limiting
# set this on test/measurement hosts

Starting with FreeBSD 8.2, cubic and htcp are supported. You can check which are available using:

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

Depending how your kernel is built, you may not have htcp/cubic by default, and will need to load the driver. To to this add 'cc_cubic_load="YES"' to /boot/loader.conf and reboot, or do a 'kldload cc_cubic'.

FreeBSD's TCP has something called inflight limiting turned on by default. This is good for modem connections, but can be detrimental to TCP throughput in some high-speed situations. If you want "normal" TCP Reno-like behavior, set inflight.enable to 0.

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.

This will still cache values for 5 minutes, for reasons described in this article from the Centre for Advanced Internet Architectures (CAIA) at Swinburne University in Australia. This article has a lot of other good tuning information for FreeBSD too. They also have a H-TCP patch for FreeBSD 7.X that works great.

FreeBSD and IPV6

Our testing has shown that on end-to-end 10G paths, IPV6 appears to be about 40% slower than IPV4 on FreeBSD 7.3, and 20% slower on FreeBSD 8.2. This is a known FreeBSD issue, and will be addressed in a future release.