国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

Nginx使用的php-fpm的兩種進程管理方式及優化

2024-08-30 12:26:02
字體:
來源:轉載
供稿:網友

PS:前段時間配置php-fpm的時候,無意中發現原來它還有兩種進程管理方式。與Apache類似,它的進程數也是可以根據設置分為動態和靜態的。

php-fpm目前主要又兩個分支,分別對應于php-5.2.x的版本和php-5.3.x的版本。在5.2.x的版本中,php-fpm.conf使用的是xml格式,而在新的5.3.x版本中,則是和php.ini一樣的配置風格。
在5.2.x版本中,php-fpm.conf中對于進程管理號稱是有兩種風格,一種是靜態(static)的,一種是類似于apache風格(apache-like)的。

代碼如下:
Process manager settings
<value name=”pm”>
Sets style of controling worker process count.
Valid values are 'static' and ‘apache-like'
<value name=”style”>static</value>

按照文檔的說明,如果pm的style采用apache-like,啟動的進程數應該是和StartServers指定的一樣。不過經過數次的嘗試,會發現,實際上在這里將pm的style配置成apache-like沒有起任何作用。也就是說,這里的apache-like并沒有被實現。
不過,在最新的5.3.x的配套php-fpm中,apache風格的進程管理已經被實現了。

代碼如下:
; 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:
; 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.
; Note: This value is mandatory.
;pm = dynamic
pm = static

由上面一段文字可知,對于進程的管理存在兩種風格——static和dynamic。和之前的版本的進程管理其實還是一樣的,只是將apache-like改成了dynamic,這樣更容易理解。

如果設置成static,php-fpm進程數自始至終都是pm.max_children指定的數量,不再增加或減少。
如果設置成dynamic,則php-fpm進程數是動態的,最開始是pm.start_servers指定的數量,如果請求較多,則會自動增加,保證空閑的進程數不小于pm.min_spare_servers,如果進程數較多,也會進行相應清理,保證多余的進程數不多于pm.max_spare_servers。

這兩種不同的進程管理方式,可以根據服務器的實際需求來進行調整。

這里先說一下涉及到這個的幾個參數,他們分別是pm、pm.max_children、pm.start_servers、pm.min_spare_servers和pm.max_spare_servers。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沧州市| 威远县| 肥东县| 汾阳市| 西乌珠穆沁旗| 宁安市| 昌江| 福鼎市| 九龙县| 金湖县| 高州市| 察哈| 菏泽市| 石门县| 壤塘县| 长沙县| 民权县| 桑植县| 大足县| 梁河县| 正安县| 白山市| 昌平区| 铁岭市| 普兰县| 牙克石市| 香格里拉县| 定襄县| 辉县市| 两当县| 绥棱县| 沈丘县| 丰都县| 阳东县| 常宁市| 巨野县| 锡林浩特市| 皮山县| 新兴县| 清原| 长岭县|