TIME_WAITs and sustained connections was: Re: Memcached module -- unix domain socket support? (too man

Tyler Kovacs tyler.kovacs at zvents.com
Sun Aug 10 23:09:10 MSD 2008

> what is the operating system?
> what do you mean tweaked(details pls.)?

I am seeing the same behavior on Centos 4.5 with nginx 0.6.32 and
memcached 1.2.6.

After running load tests using apache bench, I see a high number
of TIME_WAIT connections from netstat.  The load tests hits nginx
which fetches static response from memcached.

$ uname -a
Linux geocode1.admin.zvents.com 2.6.9-55.ELsmp #1 SMP Wed May 2 14:04:42 EDT
2007 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/redhat-release
CentOS release 4.5 (Final)

$ netstat -an |grep -c TIME_WAIT

$ ab -c 4 -n 20000 'http://localhost/geocode?address=94131'

$ netstat -an |grep -c TIME_WAIT

If I run the test again, I see a number of errors in error.log that look
like this:

2008/01/31 20:49:30 [crit] 24806#0: *70538 connect() to
failed (99: Cannot assign requested address) while connecting to
upstream, client:, server: www.xxxxxxxxxx.com, request:
"GET /geocode?address=94131 HTTP/1.0", upstream: "memcached://",
host: "www.xxxxxxxxxx.com"

I believe this is a consequence of having too many sockets in TIME_WAIT.

Finally, I think the original poster was referring to the following kernel

net.ipv4.ip_local_port_range = 1024  65000

More information about the nginx mailing list