Blog by Edo Frederix edofrederix@gmail.com RSS

Tuning TCP

March 2, 2008

Abstract

TCP configuration is essential on Linux Debian webservers. Read how to do this.

It looks like our webservers are dealing with misconfigured network connections. I’ve been reading some documentation here, here and here. Evidently, the debian etch kernel is not propperly configured for high traffic servers. I had to edit the /etc/sysctl.conf file, and appended the following lines:

net.ipv4.tcp_wmem = 4096 65536 524288
net.core.wmem_max = 1048576
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_tw_recycle = 1
net.core.rmem_max = 16777216
net.core.rmem_default = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_syncookies = 1
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
net.ipv4.netfilter.ip_conntrack_max = 1048576
net.nf_conntrack_max = 1048576

As I have learned, the

net.ipv4.tcp_wmem

option seems to be quite important. I’ll be benchmarking and studying the behaviour and effects of tuning TCP in the future.