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

I have a nginx server with load balancing and reverse proxy. Right now its behing another nginx but very soon I plan to make it front, where it will receive TCP connections from clients directly at a rate of 500req/second

I am having some big troubles with the server. I have pasted my configurations here and I am kinda sure that the problem is with ipconntrac and similar things which are alient to me

http://paste.org/pastebin/view/28543

root@load_balancer:/proc/sys/net/ipv4# netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
     67 CLOSING
    727 ESTABLISHED
    173 FIN_WAIT1
    183 FIN_WAIT2
     19 LAST_ACK
      5 LISTEN
    447 SYN_RECV
      1 SYN_SENT
  27970 TIME_WAIT

Its a ubuntu machine with mainly nginx (load balancer and reverse proxy) installed.

It surely isnt great. Can you help me understand whats going on and how can I fix it. This is my live server and I am sure its in a bad shape right now. Any document or commands to fix this, or settings I should make to make this better and reduce time wait and fin_wait1/2 better would be awesome.

share|improve this question
    
root@li235-57:/proc/sys/net# cat ./nf_conntrack_max 65536 –  Sparsh Gupta Feb 7 '11 at 20:59
add comment

2 Answers

up vote 3 down vote accepted

Try the following:

echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse

Probably it will help to reduce the number of TIME_WAIT connections. You can also make these changes permanent in /etc/sysctl.conf:

net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=1
share|improve this answer
add comment

TIME_WAIT is the state connections go into when you use the Keep Alive feature. The default is to keep connections alive for 75 seconds as Nginx uses hardly any resources to just keep an open connection. If you feel this is to excessive for your OS or needs you can reduce it (or remove it).

share|improve this answer
    
Nope. TIME_WAIT is nothing to do with this - TIME_WAIT is when a connection has been closed. –  Mez Jan 18 '12 at 10:44
    
Yeah and keep alive will keep it in TIME_WAIT state instead of fully closing the connection. But thanks for the incorrect downvote. –  Martin Fjordvald Jan 18 '12 at 15:50
    
No, it won't. KeepAlive will keep it in ESTABLISHED. –  Mez Jan 20 '12 at 16:34
add comment

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.