1、配置文件指令
1.1、全局配置指令
process.max
master进程能够Fork的最大FPM进程数。默认不启用
1.2、进程池配置指令
pm
设置进程管理器如何管理子进程。可用值:static,ondemand,dynamic。必须设置。其中:为static时,该进程池能够创建的子进程数为 pm.max_children的值;为dynamic时,该进程池启动时能够创建的子进程数为pm.start_servers的值。最大值为 pm.max_children的值
2、指令关系
即全局配置文件process.max与进程池配置文件的pm.max_children关系
2.1、默认配置
进程池默认配置内容
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
启动php-fpm,并查看进程关系
即当进程池为动态创建子进程时,默认启动的子进程数为pm.start_servers数。其值=pm.min_spare_servers+(pm.max_spare_servers-pm.min_spare_servers)/2
2.2、修改进程池为static模式
配置文件内容
pm = static
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
启动php-fpm,并查看进程关系
即当进程池为静态创建子进程时,默认启动的子进程数为pm.max_children数。其中如pm.start_servers、pm.min_spare_servers、pm.max_spare_servers则被忽略
2.3、修改全局和进程池配置
全局
process.max = 4
进程池配置
pm = static
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
启动php-fpm,并查看进程关系
即当前创建的子进程数为4个,而不是pm.max_children的值。按照这种的方式,分别修改全局和进程池配置。可以得到如下表的内容
全局 | 进程池 | 结果 |
process.max = 4 | pm = static pm.max_children = 5 | worker进程为4个。即worker进程数以process.max为主 |
process.max = 4 | pm = static pm.max_children = 3 | worker进程为3个。即worker进程数以pm.max_children为主 |
process.max = 4 | pm = dynamic pm.start_servers = 2 | worker进程为2个。即worker进程数以pm.start_servers为主 |
process.max = 1 | pm = dynamic pm.start_servers = 2 | worker进程为1个。即worker进程数以process.max为主 |