Fastcgi_keep_conn consuming ports?

I wanted to try the new “fastcgi_keep_conn on;” configuration setting. I
grabbed 1.1.13 and added the setting to my configuration. It seems to
function, but I started getting HTTP 502 errors when I put load on the
server. Looking at netstat, it seems to be consuming all available
ports:

netstat -nt > stat.txt
grep TIME_WAIT stat.txt | wc -l
49894

Everything works fine if I comment the configuration line out, which
leaves me a bit puzzled as to what is going on. Is there perhaps some
other setting I should be changing?

nginx -V
nginx version: nginx/1.1.13
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)

-Scott

Hello!

On Fri, Jan 06, 2012 at 03:02:54PM -0800, Scott Conger wrote:

Everything works fine if I comment the configuration line out,
which leaves me a bit puzzled as to what is going on. Is there
perhaps some other setting I should be changing?

nginx -V
nginx version: nginx/1.1.13
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)

If you want to use persistent fastcgi connections, you should use
fastcgi_keep_conn and keepalive directive in the upstream block,
i.e.

upstream backend {
    server ...;
    keepalive 5;
}

server {
    ...

    location / {
        fastcgi_pass backend;
        fastcgi_keep_conn on;
        ...
    }
}

Using fastcgi_keep_conn by itself only moves responsibility of
closing fastcgi connections from backend to nginx, and thus moves
TIME_WAIT connections from backend(s) to nginx side as well.

Maxim D.

Hello Maxim,

Is there any place where both directives are well documented? I tried
wiki and the new nginx documentation, but no luck so far…

Appreciated!

Andrejs

Posted at Nginx Forum:

Hello!

On Sat, Jan 07, 2012 at 06:08:09PM -0500, locojohn wrote:

Hello Maxim,

Is there any place where both directives are well documented? I tried
wiki and the new nginx documentation, but no luck so far…

Official documentation is expected to appear soon on nginx.org.

Maxim D.

On Jan 8, 2012, at 4:03 AM, Maxim D. wrote:

Maxim D.

It’s now here (done by Ruslan E.)

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_keep_conn

Thank you Andrew!

Andrejs

Posted at Nginx Forum: