Check this outRead More
Applications that handle a huge number of TCP connections, either as a server, or as a client, will often see a large number of sockets in TIME_WAIT state.
The sockets in TIME_WAIT can be seen with the “netstat -epn –tcp ” command.
If the number of TIME_WAIT sockets gets too large, your address space will be exhausted, causing a disruption of TCP traffic.
If you try a little Googling, you may be find tcp_fin_timeout option .
Do not be confused by the /proc/sys/net/ipv4/tcp_fin_timeout config item. The FIN TIMEOUT is not the same as the TIMEWAIT length.
You can force the kernel to reuse the TIME_WAIT buckets though, by setting the /proc/sys/net/ipv4/tcp_tw_recycle entry to 1. I have tested this, and it works: very few TIME_WAIT entries will be present when using this setting.
# echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
add net.ipv4.tcp_tw_recycle = 1 to /etc/sysctl.conf .