1

We are running a traditional LAMP platform with lots of visitors (don't have the numbres). On our webserver we are no getting lots of TIME_WAIT. I have googled around a lot, and think I understand how the TIME_WAIT works. But I haven't figured out if it really is a problem for us.

The reason I continue my investigation is that our web-server several times a day have problem to even provide static files. It could take up to 30 seconds to deliver some files. And then a couple of minutes later, they a delivered in ms. At the same time other static and dynamic pages are delivered in ms.

I understand that the problem could be because of numbers of different reasons. But I would like to explore this area a bit more, before looking for problems elsewhere.

QUESTION

  • Is my TIME_WAIT:s a problem?
  • What can I do to reduce them?

Here is some output from the server.

First some tweaks I did after googling, they didn't change a thing.

[root@web]# cat /proc/sys/net/ipv4/tcp_tw_reuse
1
[root@web]# cat /proc/sys/net/ipv4/tcp_fin_timeout
30
[root@web]# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
30
[root@web]# cat /proc/sys/net/ipv4/tcp_keepalive_probes
5

Some netstat output

[root@web]# date
Mon Apr 15 23:08:17 CEST 2013
[root@web]# netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
      1 CLOSE_WAIT
     39 CLOSING
    117 ESTABLISHED
     45 FIN_WAIT1
      3 FIN_WAIT2
      5 LAST_ACK
     14 LISTEN
     20 SYN_RECV
   1155 TIME_WAIT
[root@web]# netstat --numeric-hosts |grep "mysql" |wc -l
377
[root@web]# netstat --numeric-hosts |grep "mysql.*TIME_WAIT" |wc -l
361
[root@web]# netstat --numeric-hosts |grep "http" |wc -l
1039
[root@web]# netstat --numeric-hosts |grep "http.*TIME_WAIT" |wc -l
842
[root@web]# date
Mon Apr 15 23:08:21 CEST 2013

I don't see any problems on the mysql server .

[root@mysql]# netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
     21 ESTABLISHED
      7 LISTEN
    128 TIME_WAIT
[root@mysql]# netstat --numeric-hosts |grep "mysql" |wc -l
147
[root@mysql]# netstat --numeric-hosts |grep "mysql.*TIME_WAIT" |wc -l
127
show proceslist - displays about 10 sleep processes

Some links I found useful

http://antmeetspenguin.blogspot.se/2008/10/timewait-in-netstat.html http://www.speedguide.net/articles/linux-tweaking-121

Arlukin
  • 319
  • 1
  • 3
  • 12

0 Answers0