5

I'm running Squid 3.3 (EPEL) on CentOS 7 and recently I have been getting the following error message in my cache.log

WARNING! Your cache is running out of filedescriptors

I am slightly confused by this because I seem to have ample descriptors available:

squidclient mgr:info | grep 'file descri'
Maximum number of file descriptors:   16384
Available number of file descriptors: 16326
Reserved number of file descriptors:   100

Squid was also compiled with this flag:

--with-filedescriptors=16384

Squid confirms that these are actually available on startup:

2015/08/18 21:11:45 kid1| With 16384 file descriptors available

However this error keeps occurring. Not long after this error is logged the squid process seems to also hit 100% CPU or use nearly all of the system memory up over 90%, causing the internet speed to drop to a crawl or just hang indefinitely. Killing the process and restarting resolves it but eventually it will happen again.

I have a total of 8 GB of memory available, these are the memory/cache related parameters in my squid.conf

cache_dir ufs /var/spool/squid 16000 16 256
cache_mem 1024 MB

I am also using ufdbguard and additional helper plugins for Kerberos and NTLM authentication.

Any advice?

  • Provide dmesg output – Navern Aug 18 '15 at 20:29
  • Nothing useful, mostly firewall – James White Aug 18 '15 at 20:30
  • Have you tried solutions like this: cyberciti.biz/faq/… ? – Navern Aug 18 '15 at 20:31
  • How much files in your cache directory? find /var/spool/squid -type f | wc -l – Navern Aug 18 '15 at 20:31
  • No, because the descriptor value as it is now seems fine? Most examples show the problem when the descriptors are a low value like 1024, this isn't the case here. – James White Aug 18 '15 at 20:31
2

The number of file descriptors is set in the systemd unit file. By default this is 16384, as you can see in /usr/lib/systemd/system/squid.service.

To override this, create a locally overriding /etc/systemd/system/squid.service which changes the amount of file descriptors. It should look something like this:

.include /usr/lib/systemd/system/squid.service

[Service]
LimitNOFILE=65536

Do not edit the default file /usr/lib/systemd/system/squid.service, as it will be restored whenever the package is updated. That is why we put it in a local file to override defaults.

After creating this file, tell systemd about it:

systemctl daemon-reload

and then restart squid.

systemctl restart squid
  • Interestingly squidclient mgr:info | grep 'file descri' still reports the same value, despite changing it in systemd. I think the fact its compiled with that value is a problem. – James White Aug 27 '15 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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