Reputation: 355
I have a website running php-fpm with nginx on ubuntu with socket system, when the site reach about 1000 users my socket throws an error and shuts down I'm not sure if its system problem or PHP..
Symfony\Component\Debug\Exception\ContextErrorException] Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024, but you have descriptors numbered at least as high as 1024. --enable-fd-setsize=2048 is recommended, but you may want to set it to equal the maximum number of open files supported by your system, in order to avoid seeing this error again at a later date.
I have recompiled PHP with the following configurations -
./configure \ --enable-fpm \ --enable-pdo \ --with-pdo-mysql \ --enable-sockets \ --enable-exif \ --enable-soap \ --enable-ftp \ --enable-wddx \ --enable-pcntl \ --enable-soap \ --enable-bcmath \ --enable-mbstring \ --enable-dba \ --enable-gd-native-ttf \ --enable-zip \ --enable-calendar \ --with-mysql \ --with-mysqli \ --with-pdo-sqlite \ --with-iconv \ --with-zlib \ --with-bz2 \ --with-gettext \ --with-xmlrpc \ --with-openssl \ --with-mhash \ --with-mcrypt \ --with-xsl \ --with-curl \ --with-pcre-regex \ --with-gd \ --with-freetype-dir=/usr \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --with-ldap \ --with-pear \ --with-fpm-user=www-data \ --with-fpm-group=www-data \ --with-config-file-path=/etc/php/ \ --with-config-file-scan-dir=/etc/php/conf.d/ \ --with-libdir=lib/x86_64-linux-gnu \ --enable-fd-setsize=131072
and set the same limit in bits/typesizes.h, linux/posix_types.h
ulimit -Sn return 128000
I have also edited the /etc/security/limits.conf with the following -
www-data soft nofile 128000
www-data hard nofile 128000
soft nproc 128000
hard nproc 128000
soft nofile 128000
hard nofile 128000
** EDIT 1 :**
Just found out about a new way to check limit for specific process when I run cat /proc/1719/limits (1719 is one of the nginx process) I get max open files soft limit 1024, hard limit 4096, I believe that’s what cause the issue, though I can't find how to raise it up..
** EDIT 2 :**
fixed that soft limit by adding ulimit -n 512000 to the run script (added it to both nginx and php-fpm), but still crush with same error.
Upvotes: 0
Views: 3298
Reputation: 355
The problem was in a known PHP bug, the limit of opened files is taken from the linux system so if its 1024 while re-compiling it will ignore the --enable-fd-setsize=131072. you have to compile AFTER you change the linux system settings. Good luck :)
Upvotes: 1