Tuning TCP Sockets for web server



The  tcp_max_syn_backlog sets the number of TCP SYN packets that the server will queue before they are dropped.  Here you can see the default, this can be increased to 30000.
cat /proc/sys/net/ipv4/tcp_max_syn_backlog
1024

echo 30000 > /proc/sys/net/ipv4/tcp_max_syn_backlog

With a web server you will see a lot of TCP connections in the TIME-WAIT state.  TIME_WAIT is when the socket is waiting after close to handle packets  still in the network.  This also should be increased.  Here is the default.

cat /proc/sys/net/ipv4/tcp_max_tw_buckets
180000

echo 2000000 > /proc/sys/net/ipv4/tcp_max_tw_buckets

The number of packets that can be queued should be increased from the default of 1000 to 50000.

cat /proc/sys/net/core/netdev_max_backlog
1000

echo 50000 > /proc/sys/net/core/netdev_max_backlog

These tuning features of the TCP sockets can have significant increases in speed.  Be sure to test before and after to verify these are doing what you expect

Advertisements
Leave a comment

Leave your opinion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: