computer1:pm.max_requests = 10000computer2:pm.max_requests = 11000computer3:pm.max_requests = 12000computer4:pm.max_requests = 13000computer5:pm.max_requests = 14000直接改php-fpm源码

让每个work进程的max_requests都不一样,这样就能在业务高峰情形下防止work进程同时重启,参考如下:

//php-src/sapi/fpm/fpm/fpm.c:123行max_requests = fpm_globals.max_requests;//这里便是从php-fpm.conf中获取到的pm.max_requests进行赋值操作//改造为如下php_mt_srand(GENERATE_SEED());max_requests = fpm_globals.max_requests + php_mt_rand()&32767;//为什么利用32767?它的二进制是:111111111111111重启大法

max_requests设置为0,work进程一贯处理要求,永不退出,然后定时在业务低峰时重启php-fpm,开释内存,单机支配的情形下会导致做事不可用,负载均衡下可行。

总结:

maxphpphpfpm优化之maxrequests Webpack

核心便是max_requests参数调大,防止work进程频繁重启,max_requests大小分布均匀,防止work进程同时重启。