Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a setup where squid sits in front of a java server and acts as a reverse proxy. Recently i've load tested the site and if i fire 100 threads at it each making a request using jmeter i start getting errors in my load test tool like 'no route to host' even though the load test tool and the server are on the same machine.

if i run the following command where port 82 is the port my squid server is running on:

netstat -ann | grep 82 | wc -l

i get 22000 or something and most of them are in TIMED_WAIT. i'm thinking that maybe the huge number of sockets in the TIMED_WAIT state are starving the box of resources.

share|improve this question

4 Answers 4

A handy answer from StackOverflow:

http://stackoverflow.com/questions/760819/is-there-a-limit-on-number-of-tcp-ip-connections-between-machines-on-linux

share|improve this answer
1  
your comment helped me find this: speedguide.net/read_articles.php?id=121 TCP_TW_REUSE This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint. Default value is 0 (disabled). It is generally a safer alternative to tcp_tw_recycle echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse (boolean, default: 0) Note: The tcp_tw_reuse setting is particularly useful in environments where numerous short connections are open and left in TIME_WAIT state, such as web servers. Reusing the sockets can be very effective in reducing server load. –  drscroogemcduck Apr 19 '10 at 17:32

There are a variety of different limits that can affect the operation of your Web proxy. As sysadmin1138 mentioned, TCP connections is one of them.

Another, as Kyle managed to post before me, is the file descriptors. SQUID's default, at least with 2.6, is 1024. To increase this limit, you have to recompile increasing --with-maxfd. Even after recompiled with higher FD, the ulimit will be in effect for the user starting squid. For example to increase resource limit to 8192 run this before starting squid:

ulimit -HSn 8192

Linux defaults to pretty high on the kernel level these days, so you likely won't have to tune outside of SQUID for the FD. If you provide log output, chances are it will indicate the exact issue, and we could provide more detailed recommendations.

share|improve this answer

It could be too many open files With unix, "everything is a file", this includes sockets. You either need to increase the max open files with ulimit for the user, or possibly in the kernel as well (/proc/sys/fs/file-max). You could also play with the amount of time spent in TIME_WAIT with /proc/sys/net/ipv4/tcp_fin_timeout

share|improve this answer

If you're using Squid 2.7, you can set the number of fd's available without recompiling; http://www.squid-cache.org/Doc/config/max_filedescriptors/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.