Optimising the Operating System Kernel

When installing an operating system, that system has settings that are so general that the OS can cater for a host of different scenarios. However, when you install a server to fulfill a certain task, you can tweak the OS kernel to optimise its behaviour to the piece of software installed on it.

Tweaking the different kernels are outside the scope of this guide, please see the appropriate parts of your operating system documentation. Here are some starting points:

OSStarting Point


To optimise the Linux kernel, you may edit the /etc/sysctl.conf file, see the sysctl and sysctl.conf man pages. Use # sysctl -a to list all current setting.

The setting names can be found by browsing the /proc/sys tree. For instance, the setting net.ipv6.route.max_size corresponds to /proc/sys/net/ipv6/route/max_size


FreeBSD has also sysctl available. The OS has a great article online called Tuning Kernel Limits, which describes the various options.

Sun Solaris

Solaris uses /etc/system for setting kernel parameters. See the reference on docs.sun.com for the many options available.

Here is an example on how to tune the Linux kernel (tested on 2.6.24) for running the Apache web server and Varnish cache server. Albeit some of the settings may be redundant, this configuration is known to work and has a proven track record of serving several high traffic web sites:

net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_tw_recycle = 0
net.core.netdev_max_backlog = 30000
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2