<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
So, what is the solution? I have exactly the same problem, my nginx is
in a virtual server (openvz), working as a proxy server in front of
apache and oftenly  (after 2k-3k requests) server becomes "out of
sockets"  even I raise the allowed numbers of sockets to a very big
number. <br>
<br>
<br>
Igor Sysoev yazmış:
<blockquote cite="mid:20090408080955.GA51764@rambler-co.ru" type="cite">
  <pre wrap="">On Wed, Apr 08, 2009 at 10:47:16AM +0300, Artis Caune wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">2009/4/7 Deepan Chakravarthy <a class="moz-txt-link-rfc2396E" href="mailto:codeshepherd@gmail.com">&lt;codeshepherd@gmail.com&gt;</a>:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi,
  I am using nginx with fast-cgi .  When I run
$netstat -np | grep 127.0.0.1:9000
I find lot of connections in TIME_WAIT state. Is this because of high
keepalive_timeout value ?   When lot of people use (5 requests per second)
 nginx takes more  time to respond. System load goes more than 10 during
peak hours.
      </pre>
    </blockquote>
    <pre wrap="">This is because of how TCP works.


    </pre>
    <blockquote type="cite">
      <pre wrap="">debian:~# netstat -np | grep 127.0.0.1:9000
tcp        0      0 127.0.0.1:9000          127.0.0.1:45603
TIME_WAIT  -
tcp        0      0 127.0.0.1:9000          127.0.0.1:45601
TIME_WAIT  -
      </pre>
    </blockquote>
    <pre wrap="">
If you were on FreeBSD, you could disable TIME_WAIT on loopback
completely by setting:

    sysctl net.inet.tcp.nolocaltimewait=1
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Due to the incorrect implementation this remedy is worse than the disease.
The net.inet.tcp.nolocaltimewait relys on unlimited RST delivery, therefore
if there are too many RSTs, they will be limited by net.inet.icmp.icmplim
and you will have a lot of sockets in the LAST_ACK state on server side
instead of lot of sockets in the TIME_WAIT on client side.


  </pre>
</blockquote>
<br>
</body>
</html>