Linux limits the number of file descriptors that any one process (in this case PHP) may open. By default, in Debian and Ubuntu, this is set to 1024 - a number we frequently exceed. As a result we were encountering numerous "Too many open files" errors in PHP.
The file descriptor limit on your system can be found in the output of
ulimit -a:
[rob@rob-desktop] /# ulimit -a
core file size (blocks) 1000000
data seg size (kbytes) unlimited
file size (blocks) unlimited
max memory size (kbytes) unlimited
stack size (kbytes) 8192
cpu time (seconds) unlimited
max user processes unlimited
pipe size (512 bytes) 8
open files 1024
To increase the limit, edit
/etc/security/limits.conf and add the following lines:
user soft nofile limit
user hard nofile limit
Where
useris the username (wildcard * accepted) and
limitis the new file limit.
Log out and back in and the new file descriptor limit will be set.