大网数据广告活动
服务器运维问答

PHP struggling under heavy load - "failed to prepare the stderr pipe: Too many open files (24)"

· 52CE 我爱测

We're running a server with this software: - Plesk 12.5 - Apache 2.4.6 - nginx 1.11.1 - PHP 5.6 - Centos 6 - MySQL (MariaDB) 5.5.60 We've noticed that PHP repeatedly gives this error when our server is under heavy load. We've exp…

问题原文

原帖链接 · Robin · CC BY-SA 4.0

We're running a server with this software: - Plesk 12.5 - Apache 2.4.6 - nginx 1.11.1 - PHP 5.6 - Centos 6 - MySQL (MariaDB) 5.5.60

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.

Any suggestions for increasing PHP's max open files?

已采纳解答

原帖链接 · Henrik Pingel · CC BY-SA 4.0

The rlimit_files parameter in the php-fpm.conf files needs to be adjusted:

rlimit_files = 4096

The path to the php-fpm.conf should be something like /etc/php/5.6/fpm/php-fpm.conf

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。