Squid: WARNING! Your cache is running out of filedescriptors 2

Sometimes squid stops working and “WARNING! Your cache is running out of filedescriptors” is logged in cache.log. Restart usually resolves that problem. Temporarily though.
This article is based on http://www.cyberciti.biz/faq/squid-proxy-server-running-out-filedescriptors/ adding some Gentoo specific bits.

Squid, as a web cache should, holds a lot of files from internet on a local hard disk. It means that a lot of files are open at the same time. On busy servers this amount grows till the limit imposed by the operating system. Then no more files can be opened and squid seemingly dies.
Find out the current status can be done like this:
squidclient mgr:info | grep 'file descri'
Usually the maximum number of file descriptors is 1024. This can be raised to 8192 without major problems.

Letting squid to use more file descriptors (have more files open at the same time) needs to be done at two levels.
First, at OS level, there are limits, which can be seen with ulimit -a to raise those to 4096, we need to edit
* - nofile 4096
should do the trick.
Log out and back in again to see if that worked. Open files should be 4096 now. It would be wise to use something else instead of * when modifying limits.

Second, at squid level, there is a configuration file
is the key.

Now squid can be restarted. Squidclient should show that there are more file descriptors available now.

Leave a comment

Your email address will not be published. Required fields are marked *