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?

James White
  • 654
  • 3
  • 17
  • 32

1 Answers1

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
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • 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