您好,登錄后才能下訂單哦!
這篇文章主要介紹“php7 fpm三種模式static、dynamic和ondemand的介紹”,在日常操作中,相信很多人在php7 fpm三種模式static、dynamic和ondemand的介紹問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”php7 fpm三種模式static、dynamic和ondemand的介紹”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
我們經(jīng)常使用php-fpm,但是不一定所有人都知道fpm有三種模式,今天小年就帶大家了解一下fpm的三種模式,有需要的可以參考參考。
; 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.
pm有三種模式:static、dynamic和ondemand
這種方式比較簡單,在啟動時master按照pm.max_children配置fork出相應(yīng)數(shù)量的worker進程,即worker進程數(shù)是固定不變的。
動態(tài)進程管理,首先在fpm啟動時按照pm.start_servers初始化一定數(shù)量的worker。
運行期間如果master發(fā)現(xiàn)空閑worker數(shù)低于pm.min_spare_servers配置數(shù)(表示請求比較多,worker處理不過來了)則會fork worker進程,但總的worker數(shù)不能超過pm.max_children。
如果master發(fā)現(xiàn)空閑worker數(shù)超過了pm.max_spare_servers(表示閑著的worker太多了)則會殺掉一些worker,避免占用過多資源,master通過這4個值來控制worker數(shù)。
這種方式一般很少用,在啟動時不分配worker進程,等到有請求了后再通知master進程fork worker進程,總的worker數(shù)不超過pm.max_children,處理完成后worker進程不會立即退出,當(dāng)空閑時間超過pm.process_idle_timeout后再退出。
pm.max_children:靜態(tài)方式下開啟的php-fpm進程數(shù)量。
pm.start_servers:動態(tài)方式下的起始php-fpm進程數(shù)量。
pm.min_spare_servers:動態(tài)方式下的最小php-fpm進程數(shù)量。
pm.max_spare_servers:動態(tài)方式下的最大php-fpm進程數(shù)量。
php-fpm reload
php-fpm stop
kill SIGUSR1 php-fpm
重新使用新的文件,完成日志切割
kill SIGUSR2 php-fpm
重新啟動work進程,重新加載配置文件
Q1:啟動php-fpm進程之后,kill php-fpm master進程號,還能繼續(xù)服務(wù)嗎? A: 不能 (所有php-fpm進程都被關(guān)閉)
Q2:啟動php-fpm進程之后,kill -9 php-fpm master進程號,還能繼續(xù)服務(wù)嗎? A: 能(只kill了 master進程,work進程還在工作)
Q2:啟動php-fpm進程之后,kill php-fpm work進程號,還能繼續(xù)服務(wù)嗎?A: 能(work進程被kill后,又新起一個work進程)
php_module_startup()
fcgi_accept_request()
php_request_startup()
fmp_request_executing()
php_execute_script()
fpm_requset_end()
php_request_shutdown()
因為fpm是常駐進程,所以在
php_request_shutdown()
之后又會從fcgi_accept_request()
開始循環(huán)。
到此,關(guān)于“php7 fpm三種模式static、dynamic和ondemand的介紹”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。