PHP-FPM 的 pm 設定 – static, dynamic 及 ondemand

PHP-FPM 預設的 PM (process manager) 會設定為 “dynamic”, 除了 dynamic, 還有 static 及 ondemand, 以下是 PHP 官方對這些設定的解釋:

pm = dynamic – the number of child processes is set dynamically based on the following directives: pm.max_children, pm.start_servers,pm.min_spare_servers, pm.max_spare_servers.
(開啟的子進程會根據以下參數動態調整: pm.max_children, pm.start_servers,pm.min_spare_servers, pm.max_spare_servers.)

pm = ondemand – the processes spawn on demand (when requested, as opposed to dynamic, where pm.start_servers are started when the service is started.

pm = static – the number of child processes is fixed by pm.max_children.
(開啟的子進程數量固定為 pm.max_children 的數值.)

如果在一台記憶體較充裕的伺服器, pm 設定成 static 是較好的選擇, 因為不需要動態檢查系統的負載情況而決定開啟 process, 效能會較高, 但缺點是會佔用較多記憶體; 但如果記憶體較少, 例如只有 1GB 記憶體的 VPS, 使用 ondemand 及 dynamic 會較適合。


No Responses

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.