您好,登錄后才能下訂單哦!
這篇文章主要介紹“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的三種模式分別是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。