closed connections hanging in time_wait state

deva seetharam tagsense at yahoo.com
Sat Dec 1 04:16:40 UTC 2007


thanks for your note!
i realize that the connections in TIME_WAIT state are
not of concern as they will be closed eventually.
however, i was curious as there were several
connections in TIME_WAIT state especially when the
memcached client and server were running on the same
machine.  (i could understand FIN packets getting lost
in a network.)

i collected 100,000 packets exchanged between
memcached client and server using tcpdump (tcpdump -n
-l -c 100000 -s 0 -i lo 'port 11211'). 

i noticed that most of the times server and client
were  not properly sending the fin and/or ack packets.
for example, the server would send a FIN packet and in
response to that packet, the client didn't send its
FIN packet to continue the closing process. 

--- Steven Grimm <sgrimm at facebook.com> wrote:

> Unless your connection rate is very high, old
> connections in TIME_WAIT  
> state are nothing to worry about.. TIME_WAIT does
> not mean the  
> connections are still open. Here's a page that
> explains what TIME_WAIT  
> means (courtesy of a Google search for "tcp
> time_wait" which will  
> point you to other explanations if this one doesn't
> suffice):
> 
>
http://www.port80software.com/200ok/archive/2004/12/07/205.aspx
> 
> -Steve
> 
> 
> On Nov 28, 2007, at 12:37 PM, deva seetharam wrote:
> 
> > hello
> > we are using python memcache (ver. 1.4.0)  with
> memcached version  
> > (1.2.2) in a web application with apache2 running
> on debian 4.0.
> >
> > we notice that when we call disconnect_all() to
> close connections,  
> > the connections are not actually closed - they are
> left hanging in  
> > TCP_WAIT state.
> >
> >
> > i have included below a few of the lines i got
> from netstat -nt |  
> > grep -i 11211.
> >
> > is there anything we can do close the connections
> properly?
> >
> > thanks
> > dave
> >
> > tcp        0      0 127.0.0.1:45965        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45964        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46001        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46000        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46006        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46004        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46011        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46009        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46008        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46015        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:46014        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45987        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45991        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45990        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45995        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45994        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45993        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45992        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45999        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45998        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45997        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:45996        
> 127.0.0.1:11211          
> > TIME_WAIT
> > tcp        0      0 127.0.0.1:11211        
> 127.0.0.1:46063          
> > ESTABLISHED
> >
> 
> 



      ____________________________________________________________________________________
Be a better pen pal. 
Text or chat with friends inside Yahoo! Mail. See how.  http://overview.mail.yahoo.com/


More information about the memcached mailing list