Keepalive_timeout not working?

keepalives seem to be working, but the timeout limit I’m setting isn’t
honored it seems… Someone let me know if I’ve done something wrong or
am missing something.

I have nginx installed on Ubuntu from the stable repository at
nginx.org. Nothing has been added, nothing removed.

==================================
nginx version: nginx/1.4.2
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
–lock-path=/var/run/nginx.lock
–http-client-body-temp-path=/var/cache/nginx/client_temp
–http-proxy-temp-path=/var/cache/nginx/proxy_temp
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
–http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx
–group=nginx --with-http_ssl_module --with-http_realip_module
–with-http_addition_module --with-http_sub_module
–with-http_dav_module --with-http_flv_module --with-http_mp4_module
–with-http_gunzip_module --with-http_gzip_static_module
–with-http_random_index_module --with-http_secure_link_module
–with-http_stub_status_module --with-mail --with-mail_ssl_module
–with-file-aio --with-http_spdy_module --with-cc-opt=‘-g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2’
–with-ld-opt=‘-Wl,-Bsymbolic-functions -Wl,-z,relro’ --with-ipv6

In my http block, I have the following.

keepalive_timeout 3s;

That is the only place the string ‘keepalive’ exists.

=================================
root@web:/etc# grep -r “keepali” .
grep: ./blkid.tab: No such file or directory
Binary file ./alternatives/rsh matches
Binary file ./alternatives/rlogin matches
./nginx/nginx.conf: keepalive_timeout 3s;

Yet, when I take a look at netstat -tc, I have waay too many http
connections in a TIME_WAIT state and they seemingly stay there forever.
Obviously it’s not forever, but it’s not closing in 3 seconds.

Thanks.

Sajan P.
Owner, Noppix LLC

o: (563) 726-0371
c: (563) 508-3184

Hello!

On Thu, Aug 22, 2013 at 01:03:01PM -0500, Sajan P. wrote:

keepalives seem to be working, but the timeout limit I’m setting
isn’t honored it seems… Someone let me know if I’ve done something
wrong or am missing something.

[…]

Yet, when I take a look at netstat -tc, I have waay too many http
connections in a TIME_WAIT state and they seemingly stay there
forever. Obviously it’s not forever, but it’s not closing in 3
seconds.

TIME_WAIT is a TCP state, and any socket is expected to be in
this state on a side which does an active close for 2 * MSL
seconds after a connection is closed.

Reducing keepalive_timeout isn’t expected to reduce number of
sockets in a TIME_WAIT state. On the contrary, it may cause more
connections to be established and then closed, resulting in more
sockets in TIME_WAIT state.


Maxim D.
http://nginx.org/en/donation.html