Squid WARNING! Your cache is running out of filedescriptors
Note! This “fix” applies to RHEL / Red Hat / CentOS / Fedora.
Recently I noticed that our Squid was running a bit odd, getting stuck with CPU at 100%. After digging around in logs I found the following warning:
WARNING! Your cache is running out of filedescriptors
I found out that I just needed to rise the limit. There are multiple things that need doing.
First we will up the limit in the security/limits.conf file
Second we need to add the following line max_filedesc to squid.conf
Check the current limit:
squidclient -p 3128 mgr:info | grep ‘file descri’
Maximum number of file descriptors: 1024
Available number of file descriptors: 338
Reserved number of file descriptors: 100
So the default limit is 1024 which is not a lot if you have over 50+ clients using the Squid.
Edit the following file :
and add the following limit:
* – nofile 4096
Log off from squid (close ssh session etc) and log back in.
Run the following command to see if the new limit is in place.
ulimit -a | grep ‘open files’
open files (-n) 4096
Modify the Squid.conf and add the following line (somewhere to the bottom of the config)
Note! You can make it higher than 4096
Now restart the squid with the following command
service squid restart
Run the command from above again to verify that new limits are in place.