Optimizing the Operating System Kernel
A newly-installed operating system is not optimized for any particular use: its default settings are designed to cater for a wide range of different uses. For a server that is dedicated to performing a specific task, therefore, it makes sense to adjust the operating system's settings in order to maximize the performance of the software installed on it.
You can optimize the Linux kernel by editing
/etc/sysctl.conf
, and you can list the current kernel
settings by entering:
#
sysctl -a
You can find the names of all the possible kernel parameters you
can set by browsing the /proc/sys
tree in the file
system. The kernel parameter net.ipv6.route.max_size
,
for example, corresponds to the file
/proc/sys/net/ipv6/route/max_size
.
For further information, see your operating system documentation,
starting with the sysctl
and
sysctl.conf
man pages.
Here is an example showing how to tune the Linux kernel (tested on 2.6.24) for running an Apache web server and Varnish cache server. Some of the settings here may in fact be redundant, but nevertheless, this configuration is known to work and has a proven track record of serving several high traffic web sites:
net.core.rmem_max=16777216 net.core.wmem_max=16777216 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.ipv4.tcp_no_metrics_save=1 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