Socket connections in TIME_WAIT and apache MaxClients setting

From: Lumpkin, Buddy (Buddy.Lumpkin@nordstrom.com)
Date: Fri Jan 09 2004 - 15:56:51 EST


Hello All,

I was wondering if TCP socket connections to port 80 on an apache web
servers that show up in TIME_WAIT status count against the total number
of concurrent connections to the web server?

Last weekend I was called because a two web servers load balanced behind
BigIP were not responding to connections. I tried telnetting to port 80
on the localhost on each system, and it was not connected or rejected,
simply hung waiting for a connection. I noted that a wc -l of socket
connections to port 80 (netstat -n) was 255 or 256 (can't remember), and
that many of them were in TIME_WAIT status. It just so happens that I
have MaxClients set to 256 in httpd.conf.

I have since dropped the tcp_time_wait_interval, and the ratio of
TIME_WAIT to ESTABLISHED from netstat -n has improved considereably, I
just want clarification as to exactly how the socket closes at the
berkeley sockets level.

Lets say there is a TCP socket connection established to port 80 on a
web server (listen followed by accept I believe), then the client does a
send or sendto() with a buffer of "get / http/1.1\n\n", I would expect
apache to reply with a page, then close the socket descriptor at its end
(FIN). I believe the TIME_WAIT happens when the client doesn't close the
socket at it's end (FIN/ACK) correct?.

If apache has issued a close() on the socket descriptor, shouldn't it
regain that socket for use at the user sockets library level, even
though the socket is still in TIME_WAIT?

Im trying to figure out if it was just coincedence that the total number
of connections to port 80 were 256, or if the web server could not serve
pages any more because the socket connections in TIME_WAIT were counting
toward the maximum allowable connections to the server.

Also, there seemed to be some sort of global anomoly on this application
because I had to restart the J2EE application servers that communicate
with apache via mod_jk (I would not expect this, normally you can
restart one independent of the other), and some stand alone java
applications on the servers as well.

So to summarize the question another way, if netstat -n show this:

192.168.9.60.80 192.168.9.18.58168 16868 0 24616 0
TIME_WAIT

192.168.9.60.80 192.168.9.17.32849 16868 0 24616 0
TIME_WAIT

192.168.9.60.80 192.168.44.63.4800 64240 0 24820 0
ESTABLISHED

192.168.9.60.80 192.168.44.63.4801 62919 0 24820 0
ESTABLISHED

192.168.9.60.80 192.168.9.18.58185 16868 0 24616 0
TIME_WAIT

192.168.9.60.80 192.168.9.17.32880 16868 0 24616 0
TIME_WAIT

192.168.9.60.80 192.168.204.113.3116 63188 0 24820 0
ESTABLISHED

192.168.9.60.80 192.168.204.113.3117 64233 0 24820 0
ESTABLISHED

If the MaxClients setting in apache were set to 8, would new connections
block, or would they block once the "ESTABLISHED" connections reached a
total of 8?

I will summarize,

--Buddy
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:27:48 EDT