I am running Squid 2.7 on Ubuntu 10.04 64bits. I had the problem of Squid running out of file descriptors, with the following error showing in /var/log/squid/cache.log:
WARNING! Your cache is running out of filedescriptors
I checked with:
squidclient mgr:info | grep 'file descri'
and it showed that I had only 1024 file descriptors available.
I changed /etc/security/limits.conf, adding this at the end:
* soft nofile 32768
* hard nofile 32768
proxy soft nofile 32768
proxy hard nofile 32768
Added this to /etc/squid/squid.conf:
max_filedescriptors 32768
Also changed /etc/default/squid:
SQUID_MAXFD=32768
Nothing was working out. In the end I edited /etc/init.d/squid to add "ulimit -n 32768":
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
ulimit -n 32768
<... snipped ...>
That worked! :)
I had to do all this under the stress of a live, production Squid server being incredibly slow, so I am sure that this is NOT the right way to do it.
But what is the right way to do it?
You have to add the ulimit line in the squid init script as well as increase max_filedescriptors in squid.conf. Those are the two essential steps. You no longer have to compile squid from source to increase this limit. That was something you had to do with really old squid versions.
I had the same problem before. I was not able to increase the number of file descriptors of quid.
In addition to what you have done, I configured squid using the following configure options:
The important part for case is:
After doing this and restarting squid, I got the maximum value of file descriptors: 65536.
Of course, this requires squid to be installed from source not from the command:
/etc/init.d/squid is a symlink to /lib/init/upstart-job, so your original suggestion raises the ulimit for all upstart services.
I agree that the original question/solution raises the file descriptor limit, so thanks for that. Ideally a solution that didn't raise file descriptors across the board would be nicer.