温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php中fpm的三种模式分别是什么

发布时间:2021-07-21 19:21:42 来源:亿速云 阅读:109 作者:chen 栏目:编程语言

这篇文章主要介绍“php中fpm的三种模式分别是什么”,在日常操作中,相信很多人在php中fpm的三种模式分别是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”php中fpm的三种模式分别是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

pm有三种模式:static、dynamic和ondemand

1、static

这种方式比较简单,在启动时master按照pm.max_children配置fork出相应数量的worker进程,即worker进程数是固定不变的。

2、dynamic

动态进程管理,首先在fpm启动时按照pm.start_servers初始化一定数量的worker。

运行期间如果master发现空闲worker数低于pm.min_spare_servers配置数(表示请求比较多,worker处理不过来了)则会fork worker进程,但总的worker数不能超过pm.max_children。

如果master发现空闲worker数超过了pm.max_spare_servers(表示闲着的worker太多了)则会杀掉一些worker,避免占用过多资源,master通过这4个值来控制worker数。

3、ondemand

这种方式一般很少用,在启动时不分配worker进程,等到有请求了后再通知master进程fork worker进程,总的worker数不超过pm.max_children,处理完成后worker进程不会立即退出,当空闲时间超过pm.process_idle_timeout后再退出。

实例

; 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. With this process management, there will be
 
;             always at least 1 children.
 
;             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.
 
;  ondemand - no children are created at startup. Children will be forked when
 
;             new requests will connect. The following parameter are used:
 
;             pm.max_children           - the maximum number of children that
 
;                                         can be alive at the same time.
 
;             pm.process_idle_timeout   - The number of seconds after which
 
;                                         an idle process will be killed.
 
; Note: This value is mandatory.

到此,关于“php中fpm的三种模式分别是什么”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI