We've noticed that PHP repeatedly gives this error when our server is under heavy load. We've experienced this during peak live traffic, and also load testing on a clone of the server.
In /var/log/plesk-php56-fpm/error.log:
[07-May-2020 05:45:20] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
When we see these errors, we get a lot of 504 Gateway Timeouts.
We can see that PHP processes have a file limit of 1024, which seems too low (we've increased it for MySQL/Apache/Nginx, but can't figure out how to increase it for PHP):
In /proc/{php_process}/limits:
Max open files 1024 4096 files
We can't figure out how to increase this.
# ulimit -n
65535
In /etc/security/limits.conf:
* soft nofile 65535
* hard nofile 65535
In /proc/sys/fs/file-max:
250000
In /etc/sysctl.conf:
fs.file-max = 250000
We've restarted the server after making those changes.
Software on the server:
- Plesk 12.5
- Apache 2.4.6
- nginx 1.11.1
- PHP 5.6
- Centos 6
- MySQL (MariaDB) 5.5.60
Any thoughts on increasing PHP's max open files?
In /var/log/plesk-php56-fpm/error.log:
[07-May-2020 05:45:20] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
[07-May-2020 05:45:21] ERROR: failed to prepare the stderr pipe: Too many open files (24)
When we see these errors, we get a lot of 504 Gateway Timeouts.
We can see that PHP processes have a file limit of 1024, which seems too low (we've increased it for MySQL/Apache/Nginx, but can't figure out how to increase it for PHP):
In /proc/{php_process}/limits:
Max open files 1024 4096 files
We can't figure out how to increase this.
# ulimit -n
65535
In /etc/security/limits.conf:
* soft nofile 65535
* hard nofile 65535
In /proc/sys/fs/file-max:
250000
In /etc/sysctl.conf:
fs.file-max = 250000
We've restarted the server after making those changes.
Software on the server:
- Plesk 12.5
- Apache 2.4.6
- nginx 1.11.1
- PHP 5.6
- Centos 6
- MySQL (MariaDB) 5.5.60
Any thoughts on increasing PHP's max open files?