欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          FPM鮮為人知的三種模式

          我們經(jīng)常使用php-fpm,但是不一定所有人都知道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

          static

          這種方式比較簡(jiǎn)單,在啟動(dòng)時(shí)master按照pm.max_children配置fork出相應(yīng)數(shù)量的worker進(jìn)程,即worker進(jìn)程數(shù)是固定不變的。

          dynamic

          動(dòng)態(tài)進(jìn)程管理,首先在fpm啟動(dòng)時(shí)按照pm.start_servers初始化一定數(shù)量的worker。

          運(yùn)行期間如果master發(fā)現(xiàn)空閑worker數(shù)低于pm.min_spare_servers配置數(shù)(表示請(qǐng)求比較多,worker處理不過(guò)來(lái)了)則會(huì)fork worker進(jìn)程,但總的worker數(shù)不能超過(guò)pm.max_children。

          如果master發(fā)現(xiàn)空閑worker數(shù)超過(guò)了pm.max_spare_servers(表示閑著的worker太多了)則會(huì)殺掉一些worker,避免占用過(guò)多資源,master通過(guò)這4個(gè)值來(lái)控制worker數(shù)。

          ondemand

          這種方式一般很少用,在啟動(dòng)時(shí)不分配worker進(jìn)程,等到有請(qǐng)求了后再通知master進(jìn)程fork worker進(jìn)程,總的worker數(shù)不超過(guò)pm.max_children,處理完成后worker進(jìn)程不會(huì)立即退出,當(dāng)空閑時(shí)間超過(guò)pm.process_idle_timeout后再退出。

          pm.max_children:靜態(tài)方式下開啟的php-fpm進(jìn)程數(shù)量。

          pm.start_servers:動(dòng)態(tài)方式下的起始php-fpm進(jìn)程數(shù)量。

          pm.min_spare_servers:動(dòng)態(tài)方式下的最小php-fpm進(jìn)程數(shù)量。

          pm.max_spare_servers:動(dòng)態(tài)方式下的最大php-fpm進(jìn)程數(shù)量。

          FPM對(duì)信號(hào)的處理

          php-fpm reload

          php-fpm stop

          kill SIGUSR1 php-fpm 重新使用新的文件,完成日志切割

          kill SIGUSR2 php-fpm 重新啟動(dòng)work進(jìn)程,重新加載配置文件

          Q1:?jiǎn)?dòng)php-fpm進(jìn)程之后,kill php-fpm master進(jìn)程號(hào),還能繼續(xù)服務(wù)嗎? A: 不能 (所有php-fpm進(jìn)程都被關(guān)閉)

          Q2:?jiǎn)?dòng)php-fpm進(jìn)程之后,kill -9 php-fpm master進(jìn)程號(hào),還能繼續(xù)服務(wù)嗎? A: 能(只kill了 master進(jìn)程,work進(jìn)程還在工作)

          Q2:?jiǎn)?dòng)php-fpm進(jìn)程之后,kill php-fpm work進(jìn)程號(hào),還能繼續(xù)服務(wù)嗎?A: 能(work進(jìn)程被kill后,又新起一個(gè)work進(jìn)程)

          FPM的生命周期

          php_module_startup()

          fcgi_accept_request()

          php_request_startup()

          fmp_request_executing()

          php_execute_script()

          fpm_requset_end()

          php_request_shutdown()

          因?yàn)閒pm是常駐進(jìn)程,所以在php_request_shutdown()之后又會(huì)從fcgi_accept_request()開始循環(huán)。

          推薦學(xué)習(xí):php視頻教程

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)