Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

What are the best settings to tune so that Linux can handle a very large amount of TCP connections such as would be seen by a proxy server or a webserver?

I'm using Centos6 and squid and am seeing a large amount of TIME_WAIT connections backing up until finally the machine stops responding. The machine isn't loaded at the time, and is having trouble making ingoing and outgoing connections.

I've had several suggestions of tuning /proc/sys/net/ipv4/tcp_tw_reuse and /proc/sys/net/ipv4/tcp_tw_reuse but they mention bad interactions with load balancers and NAT both of which are used in my situation.

share|improve this question
    
Which connections / end points are causing the problems? Have you looked to check if FIN/RST packets are getting lost somewhere? –  symcbean Mar 26 '12 at 13:27
    
The issue seems to be between our load balancer and the proxy hosts. I have confirmed that no packets are going missing between the two using wireshark. –  smarthall Mar 26 '12 at 14:25

2 Answers 2

up vote 2 down vote accepted

Try to tune down this one:

net.ipv4.tcp_keepalive_time = 7200

Something like

net.ipv4.tcp_keepalive_time = 600

should be a lot better for your situation.

Also, make sure you have tuned the local port range. By default in most distros it's

net.ipv4.ip_local_port_range = 32768    61000

Something like

net.ipv4.ip_local_port_range = 1025    65534

should work lot better.

share|improve this answer

Perhaps you could try reducing the /proc/sys/net/ipv4/tcp_fin_timeout. If you're using keepalive you may want to fiddle with /proc/sys/net/ipv4/tcp_keepalive_intvl and /proc/sys/net/ipv4/tcp_keepalive_probes ?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.