Forum: NGINX keepalive_timeout not working?

27e6fb8c0fe4d1ad444b2a4967d1d6c5?d=identicon&s=25 Sajan Parikh (Guest)
on 2013-08-22 20:03
(Received via mailing list)
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 Parikh
Owner, Noppix LLC

o: (563) 726-0371
c: (563) 508-3184
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-08-22 20:35
(Received via mailing list)
Hello!

On Thu, Aug 22, 2013 at 01:03:01PM -0500, Sajan Parikh 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 Dounin
http://nginx.org/en/donation.html
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.