php-fpm:帮助理解start_servers,min_spare_servers,max_spare_servers

我试图调整我的服务器的我的php-fpm安装,我无法弄清楚如何处理pm.start_serverspm.min_spare_serverspm.max_spare_serversvariables。 我正在使用pm = dynamic

pm.max_children是完全清楚的。 每个subprocess一次为1个Web客户端提供服务。 好。 什么是“服务器”呢? 显然,根据我有的默认configuration,1个服务器可以服务超过1个孩子。 什么是上限? 我应该使用什么作为经验法则为孩子/服务器的#? 或者它是相关的? 在某个论坛上,有人声称服务器的数量应该是2 x cpu的核心,但是我已经看到了build议的configuration,其中数量更高,40-50。

PHP文档和许多“调优php-fpm”文章都没有帮助。

基本上,当你设置为dynamic时候,php-fpm随时可以运行的进程数量是非常可configuration的。 当设置为static ,总会有许多subprocess在运行。 一般来说,您将其设置为dynamic以节省资源。 每个subprocess都可以处理一个请求。 上限取决于你的php应用程序有多沉重,你得到多lessstream量。 你还应该计算每个孩子的内存消耗的平均值,并确保你永远不要让孩子的数量超过安装在你的服务器上的RAM的数量,否则你将开始交换,甚至让内核开始查杀进程。

 ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; ; dynamic - the number of child processes are set dynamically based on the ; following directives: ; pm.max_children - the maximum number of children that can ; be alive at the same time. ; pm.start_servers - the number of children created on startup. ; pm.min_spare_servers - the minimum number of children in 'idle' ; state (waiting to process). If the number ; of 'idle' processes is less than this ; number then some children will be created. ; pm.max_spare_servers - the maximum number of children in 'idle' ; state (waiting to process). If the number ; of 'idle' processes is greater than this ; number then some children will be killed. ; Note: This value is mandatory. 

设置这些选项时,请考虑以下几点:

  • 平均要求多久?
  • 网站同时访问的最大数量是多less?
  • 平均每个subprocess消耗多less内存?