ubuntu 22.04 WARNING: [pool ***] server reached max_children, consider raising it

最近 WordPress 上传图片的时候,偶尔会发生失败,报错 503。以前比较少,最近越来越频繁,于是跟踪了一下服务器的日志,看到如下报错信息:

查看 PHP 的日志,却找不到任何有用的日志,只看到如下警告:

起初是百思不得其解,按理说应该有相关报错才对。

后来仔细思考了一下,才想明白,原来是并发数超过最大限制了,默认的并发数量是 5,这个绝对是不够的,并发超过限制是没有任何报错信息的,日志只会给出一个警告。

详细的解决方案如下:

If you encounter such an error in the php logs, then it is time to modify max_children. The php logs are usually located in /var/log/,  and in my case they are in /var/log/php7.4-fpm.log

Search for the file where the max_children variable is located, in my case the file is www.conf and is located in the folder: /etc/php/7.4/fpm/pool.d/

Change the value pm.max_children = 8 to a larger one, 16 for example

save the .conf file and restart the web server:

or only the php-fpm service as follows:

Eventually you can check these logs, who knows, you may not even know you have such a problem!

** As I noticed, for HestiaCP (VestaCP) users max_children can be found in both the /etc/php/7.4/fpm/pool.d/www.conf file and the file /usr/local/hestia/php/etc/php-fpm.conf

** Attention, you must also have enough memory for this, otherwise the results are not as expected!

Check the memory used by each php-fpm service-child with the following command:

Then, to see the memory required for these processes, we need to add the rss parameter which is “Resident Set Size” or the physical memory. Note: Modify php-fpm7.4 to suit your version of PHP:

These numbers are in Kbytes , so we calculate an average of the displayed values and multiply by max_children, and we find approximately the memory needed only for php, but don’t forget, the server also needs memory for Apache, Nginx, mysql … maybe Varnish, HAproxy, Redish, etc. .. so, check these values carefully!

参考链接


Solved! WARNING: [pool ***] server reached max_children, consider raising it

发布者

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注