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

How and where to configure pm.max_children for php-fpm with Docker?

· 52CE 我爱测

In a Web application with Nginx and PHP-FPM, I've noticed moments of slowness and analyzing the logs, I found this message, which appears from time to time: [19-Nov-2017 19:24:09] WARNING: [pool www] server reached pm.max_childre…

问题原文

原帖链接 · lfalmeida · CC BY-SA 3.0

In a Web application with Nginx and PHP-FPM, I've noticed moments of slowness and analyzing the logs, I found this message, which appears from time to time:

[19-Nov-2017 19:24:09] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

After some reseach, I increased the values in the php.ini configuration file, stopped and removed the php container and rebuild it, for the setting set to a file on a volume had effect.

Analyzing the configuration file inside the container, it's with the new values that I set, however, the error message about pm.max_children (5) continues to appear.

Here is my docker-compose.yml

version: '2'

services:           

    pi_web:
        build: ./nginx
        ports:
            - "80:80"
            - "443:443"

        volumes:
            - ../src:/src
            - ./nginx/conf.d:/etc/nginx/conf.d
            - ./nginx/nginx.conf:/etc/nginx/nginx.conf
            - /etc/letsencrypt:/etc/letsencrypt

    pi_php:
        build: ./php
        volumes:
            - ../src:/src
            - ./php/config/php.ini:/usr/local/etc/php/php.ini

Here is a snippet of the ./php/config/php.ini:

pm = dynamic
pm.max_children = 40
pm.start_servers = 15
pm.min_spare_servers = 15
pm.max_spare_servers = 25

And, if I run:

$ docker exec -it docker_pi_php_1 cat /usr/local/etc/php/php.ini

I see the same values on the snippet above.

The path to the configuration file inside the container is correct, I ran:

$ php --ini 

inside the container and the path is in the list of loaded configuration files.

I've fried my brain trying to get around this problem, but so far I haven't succeeded.

Any ideas?

已采纳解答

原帖链接 · Miguel A. C. · CC BY-SA 4.0

I may be wrong, but assuming you're using the official PHP images those pm settings should be placed inside the /usr/local/etc/php-fpm.d/ directory inside a file with conf extension. According to PHP docs, those settings are FPM related and although they use php.ini syntax, they should be placed in a different file, so I believe that your pm settings are being ignored. This Dockerfile in PHP helped me to find out where are those conf files supposed to be.

I'd check if you have a /usr/local/etc/php-fpm.d/www.conf file inside your container where that max_children is now set to 5. If that is so I guess you could modify your Dockerfile to copy a new www.conf file that sets a higher value for pm.max_children.

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

资料来源与适用范围

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

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

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