Lots of CLOSE_WAIT sockets, nginx+php (WordPress site)

Vicente Aguilar bisente at bisente.com
Mon Feb 22 09:46:24 MSK 2010

>> We're going to start using WP-mu at work so I've been looking 
>> into it lately and the problem seems to be browser-server 
>> connections stuck on the CLOSE_WAIT state. With netstat -nap I 
>> get loads of these:
>> $ netstat -nap | grep CLOSE_WAIT
>> tcp        1      0     
>> CLOSE_WAIT  27672/nginx: worker
> [...]
> What does nginx -V show?  What's in config?

You're right, should have started there. Sorry. :-)

$ nginx -V
nginx version: nginx/0.7.65
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-http_sub_module --with-mail --with-mail_ssl_module --with-ipv6 --with-http_perl_module --add-module=/usr/src/debian/nginx/nginx-0.7.65/modules/nginx-upstream-fair --add-module=/usr/src/debian/nginx/nginx-0.7.65/modules/ngx_http_upstream_memcached_hash_module-0.04 --add-module=/usr/src/debian/nginx/nginx-0.7.65/modules/ngx_http_secure_download --with-http_proxy_s3_auth

some bits of nginx config:

worker_processes  4;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    multi_accept on;
http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  20;
    keepalive_requests 50;
    tcp_nodelay        on;

    gzip  on;

client_max_body_size 32m;

  gzip_static on;

  gzip_http_version   1.1;
  gzip_proxied        expired no-cache no-store private auth;
  gzip_disable        "MSIE [1-6]\.";
  gzip_vary           on;

    location ~ .php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_index  index.php;
        include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SERVER_NAME $http_host;
       fastcgi_param  QUERY_STRING     $query_string;   
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;  
        fastcgi_param  CONTENT_LENGTH   $content_length;
        fastcgi_intercept_errors        on;  
        fastcgi_ignore_client_abort on;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;   
        fastcgi_temp_file_write_size 256k;

All the rest are the usual locations, rewrites, etc.

Have tried with several different combinations of worker_processes, sendfile, nopush, keepalive_* ... to no avail. Sometimes it takes longer to hang, but it always end up not responding with > 100 connections in CLOSE_WAIT. Killing nginx, waiting a couple of seconds for the connections in CLOSE_WAIT to disappear from netstat and starting nginx again fixes the issue. No need to restart the PHP processes.


  Vicente Aguilar <bisente at bisente.com> | http://www.bisente.com

More information about the nginx mailing list