Chapter 4. Tuning the operating system 131
Draft Document for Review May 4, 2007 11:35 am 4285ch04.fm
Tuning TCP behavior
Here we describe some of tuning parameters that will change TCP behaviors.
The following commands can be used for tuning servers that support a large number of
multiple connections:
򐂰For servers that receive many connections at the same time, the TIME-WAIT sockets for
new connections can be reused. This is useful in Web servers, for example:
sysctl -w net.ipv4.tcp_tw_reuse=1
If you enable this command, you should also enable fast recycling of TIME-WAIT sockets
status:
sysctl -w net.ipv4.tcp_tw_recycle=1
Figure 4-17 shows that with these parameters enabled, the number of connections is
significantly reduced. This is good for performance because each TCP transaction
maintains a cache of protocol information about each of the remote clients. In this cache,
information such as round-trip time, maximum segment size, and congestion window are
stored. For more details, review RFC 1644.
Figure 4-17 Parameters reuse and recycle enabled (left) and disabled (right)
򐂰The parameter tcp_fin_timeout is the time to hold a socket in state FIN-WAIT-2 when the
socket is closed at the server.
A TCP connection begins with a three-segment synchronization SYN sequence and ends
with a three-segment FIN sequence, neither of which holds data. By changing the
tcp_fin_timeout value, the time from the FIN sequence to when the memory can be freed
for new connections can be reduced, thereby improving performance. This value, however,
With both
tcp_tw_reuse and
tcp_tw_recycle
enabled, the
information about
the hosts does not
have to be obtained
again and the TCP
transaction can
start immediately,
preventing the
unnecessary traffic.
tcp_tw_reuse and
tcp_tw_recycle
enabled.
tcp_tw_reuse and
tcp_tw_recycle
disabled.