什么是 PHP-FPM 池,什么是 pm.max_children?

2022-01-23 00:00:00 nginx php drupal-7

我有一个带有 NGINX 和 PHP-FPM 的 Drupal 站点,带有 3 个池.

I have a Drupal site with NGINX and PHP-FPM with 3 pools.

我想知道什么是 FPM 池,或者只是给我提供好的文档的链接,我已经搜索过这个主题,但我发现的只是如何配置X"以获得更好的性能.

What I want to know is what are FPM pools or just give me links to good documentation, i've searched about this topic but all I found is how to configure "X" to obtain a better performance.

另外,什么是 pm.max_children?我最近在日志中注意到,当池 www1 达到此值时,池 www1 停止工作,同时锁定我网站上的一个页面,直到我重新加载 PHP-FPM.为什么我会在一段时间后到达 pm.max_children?有没有办法在这种情况下检测并做出反应……重新加载 PHP-FPM?有没有办法避免到达 pm.max_children?

Also, what is pm.max_children? I recently notice in the log that when pool www1 reaches this value the pool www1 stops working, locking also a page on my site until I reload PHP-FPM. Why I'm reaching pm.max_children after some time? Is there a way to detect and react in this event... reloading PHP-FPM? Is there a way to avoid reaching pm.max_children?

感谢大家的知识.

PD:我正在使用 perusio 的 Drupal 和 Nginx 配置.

PD: I'm using perusio's configuration for Drupal and Nginx.

推荐答案

嗯,你可以简单地说每个池就像一个单独的 php,就像我使用池来由不同的用户运行每个池,给每个池适当的限制在资源等方面,对于在同一服务器上运行的不同网站.

Well you can simply say that each pool is like a separate php, like for me i use pools to run each by a different user, give each the appropriate limits in terms of resources and such for separate websites running on the same server.

我不明白为什么同一个站点有 3 个池,你在 nginx 中使用 upstream 吗?

I don't understand though why 3 pools for same site, do you use an upstream in nginx?

至于 max_children 是允许 fpm 产生以处理并发连接的产生进程的数量,如果你有很多并发连接,那么你最好增加这个数字,如果这个数字是达到 fpm 不会产生另一个孩子并等待一个有空闲来处理等待请求.

As for max_children is the amount of spawned processes the fpm is allowed to spawn to handle concurrent connections, If you are having a lot of concurrent connections then you better increase that number, if the number is reached fpm won't spawn another child and wait for one to free to handle the waiting request.

编辑:

尝试使用此配置,可能有用,这是配置文件的片段,默认情况下已注释.

Try playing with this config, might be useful, here's a snippet from the config file, by default it's commented.

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For 
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

还有一个

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0

相关文章