SQUID performance / crash because of file descriptor ulimit 1024
During heavy loads our ResNet Proxy performes badly and occasionally even crashes.
/var/log/squid/cache.log
Squid Cache (Version 3.3.10): Terminated abnormally.
FATAL: Ipc::Mem::Segment::open failed to shm_open(/squid-squid-page-pool.shm): (2) No such file or directory
FATAL: Too few filedescriptors available in the system (72 usable of 16384).
squidclient reportes enough file descriptor available:
squidclient -p 8081 mgr:info
Maximum number of file descriptors: 98304
Largest file desc currently in use: 309
Number of file desc currently in use: 65
Available number of file descriptors: 98239
Solution
cause for this is the following file /etc/conf.d/squid where there is the file descriptor ulimit set to only 1024!
/etc/conf.d/squid
# Max. number of filedescriptors to use. You can increase this on a busy
# cache to a maximum of (currently) 8192 filedescriptors. Default is 1024.
SQUID_MAXFD=1024
This is a very outdated size that is delivered with squid package up to now. Something up to 32k could be reasonable for a dedicated proxy.
Nevertheless, this setting is limited by the /etc/init.d/squid script which+ limits to 8192+ as well, so a update of that script should be needed too.
(from redmine: issue id 2850, created on 2014-04-18, closed on 2014-05-06)
- Changesets:
- Revision 6fb74a8e by Natanael Copa on 2014-04-25T18:08:57Z:
main/squid: disable hardcoded --max-filedescriptors
Use what ever is the system default (with ulimit) or let user configure
in squid.conf
ref #2850
- Revision 6a318d9b by Natanael Copa on 2014-04-28T11:41:12Z:
main/squid: allow more than 16384 filedescriptors
It seems that when squid is compiled with --with-filedescriptors, that
becomes a hard limit[1]. Without this compile option it will use the
system ulimit setting, which is the behaviour we want.
For compatibility we set SQUID_MAXFD to 16384 if unset but still allow
it to go over 16384 if needed. It should also be possible to set
max_filedescriptors in squid.conf[2].
fixes #2850
[1] https://bugzilla.redhat.com/show_bug.cgi?id=976815
[2] http://www.squid-cache.org/Versions/v3/3.3/cfgman/max_filedescriptors.html