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

How to determine the best setting for php-fpm pm.max_requests?

· 52CE 我爱测

I'm not much of a system / network administrator. I'm searching for a way to properly determine the settings of my php-fpm. So far I found this article explaining the details to calculate these settings based on the server specs …

问题原文

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

I'm not much of a system / network administrator. I'm searching for a way to properly determine the settings of my php-fpm.

So far I found this article explaining the details to calculate these settings based on the server specs (https://chrismoore.ca/2018/10/finding-the-correct-pm-max-children-settings-for-php-fpm/):

pm.max_children
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers

But there's a setting here pm.max_requests, so I'm wondering what value I should put here? How do I determine what value I should put there? Should I leave it at default 0?

已采纳解答

原帖链接 · Rino Bino · CC BY-SA 4.0

The only possible answer here is that there is no exact answer to give.

It really depends. Performance settings are solely dependent on each use-case, specs, project structure, etc.


You should only set a value here if you have a reason to.

If you don't care how many requests each process can get before restarting, you should just leave it at the default setting.

The same can be said for most settings in all sorts of applications, not just PHP-FPM.


From the docs:

pm.max_requests

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.

So, ask yourself: Are you having an issue with memory leaks, hung connections, etc? If so, maybe this functionality would be useful to you. If not, maybe just leave it alone.

I'll summarize with an analogy: Just because you have a workshop full of tools, it does not mean you need every tool for every job. This setting only needs to be configured if there is a problem to solve.

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

资料来源与适用范围

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

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

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