Squid: WARNING! Your cache is running out of filedescriptors

1:38 AM 0 Comments


So you have a LAN with 50+ users and you set up a nice Squid w3cache as a transparent proxy with 100GB of space reserved for the cache (hdds are so cheap nowadays…). Weeks pass and suddenly you notice that something is messing up your
web experience as Firefox suddenly decides to run painfully slow. About 30 minutes wasted on finding the culprit (like changing your DNS servers, clearing browser cache, etc.) until you decide to check the router and then Squid and then its logs. And then you find something fishy:
WARNING! Your cache is running out of filedescriptors
I won’t be explaining why this happens. Others have done it before. What I’m going to do is present you with a solution that does not require a complete Squid recompilation/reinstallation procedure.
However, I believe it requires a fairly modern setup to work. I was using Squid 2.6 STABLE6 on Fedora Core 6 with 2.6.18 kernel. Your mileage may vary.

Squid increase the maximum file descriptors

First, update /etc/security/limits.conf file:
# vi /etc/security/limits.conf
Append following line to increase current limit from 1024 to 8192:
* - nofile 8192
Save and close the file. You must re-login to check new limits:
# ulimit -a | grep 'open files'
Sample output:
open files                      (-n) 8192

Stopping the Squid

This is important:
/etc/init.d/squid stop

/etc/squid/squid.conf

At the very end of this file there is a line which needs adding/changing so it reads:
max_filedesc 8192

/etc/init.d/squid

Just after the comments (before any code) add this line:
ulimit -HSn 8192

/usr/include/bits/typesizes.h

Edit the __FD_SETSIZE line so it reads:
#define __FD_SETSIZE            8192

Starting the squid

/etc/init.d/squid start
And now watch the /var/log/squid/cache.log for a similar line:
2007/01/01 18:32:27| With 8192 file descriptors available
If it still says 1024 file descriptors available (or similarly low value) you are out of luck (or you’ve just messed something up).

Install Server Networking Programming

Support you how to install server, networking and Programming Easy

0 comments:

You can post comment with english language or indonesia language.
Anda bisa memberikan komentar dalam bahasa inggris atau bahasa indonesia.