Our squid Web cache had a few hiccups today because we suddenly had a dramatic increase in connections, having to temporarily work around a failed Citrix Web interface.

Internet surfing crawled (pun intended) to an almost-stillstand as I noticed the dreaded:

WARNING: Your cache is running out of filedescriptors

in squid’s cache.log file.

The fix is quite easy, unless you have older Linux and/or squid versions.

For squid 2.5 and higher, the magic switches are two-fold:

  • Increase the system’s file-descriptor limits.
  • Modify squid’s configuration to accomodate the higher limits.

What I did was to edit squid’s startup script (here: /etc/init.d/squid) to add the line

ulimit -HSn 32768

just before squid is launched.

I then added the line

max_filedesc 32768

to squid.conf.

After restarting squid, I checked the cache.log, and was glad to see:

Starting Squid Cache version 2.5.STABLE14 for x86_64-redhat-linux-gnu...
Process ID 20567
With 32768 file descriptors available
DNS Socket created ...

I’m happy, and our users are very happy. :-)

Software and Linux :: 05 Jun 2009 :: e-mail