這篇文章主要介紹“php中fpm的三種模式分別是什么”,在日常操作中,相信很多人在php中fpm的三種模式分別是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”php中fpm的三種模式分別是什么”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
合水ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
pm有三種模式:static、dynamic和ondemand
1、static
這種方式比較簡單,在啟動時master按照pm.max_children配置fork出相應(yīng)數(shù)量的worker進(jìn)程,即worker進(jìn)程數(shù)是固定不變的。
2、dynamic
動態(tài)進(jìn)程管理,首先在fpm啟動時按照pm.start_servers初始化一定數(shù)量的worker。
運(yùn)行期間如果master發(fā)現(xiàn)空閑worker數(shù)低于pm.min_spare_servers配置數(shù)(表示請求比較多,worker處理不過來了)則會fork worker進(jìn)程,但總的worker數(shù)不能超過pm.max_children。
如果master發(fā)現(xiàn)空閑worker數(shù)超過了pm.max_spare_servers(表示閑著的worker太多了)則會殺掉一些worker,避免占用過多資源,master通過這4個值來控制worker數(shù)。
3、ondemand
這種方式一般很少用,在啟動時不分配worker進(jìn)程,等到有請求了后再通知master進(jìn)程fork worker進(jìn)程,總的worker數(shù)不超過pm.max_children,處理完成后worker進(jìn)程不會立即退出,當(dāng)空閑時間超過pm.process_idle_timeout后再退出。
實(shí)例
; 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.
到此,關(guān)于“php中fpm的三種模式分別是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!