PHP-FPM pm.min spare servers

IT 위키
Prairie (토론 | 기여)님의 2024년 12월 1일 (일) 08:56 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

pm.min_spare_servers is a configuration directive in PHP-FPM (FastCGI Process Manager) used to specify the minimum number of idle (spare) worker processes that should be maintained in the pool. It is applicable when the process manager (pm) is set to dynamic. This directive ensures that there are always enough idle workers available to handle incoming requests without unnecessary delays.

Overview[편집 | 원본 편집]

When PHP-FPM is configured to use the dynamic process management mode, it automatically adjusts the number of worker processes based on server load. The `pm.min_spare_servers` directive sets a lower limit on the number of idle worker processes to ensure that the server can quickly respond to spikes in traffic.

Key characteristics:

  • It defines the minimum number of idle worker processes.
  • Applies only in dynamic process management mode.
  • Helps reduce latency by ensuring that spare workers are pre-allocated.

Default Value[편집 | 원본 편집]

The default value of `pm.min_spare_servers` is system-dependent but is typically set to `1` or `2`.

Configuration Example[편집 | 원본 편집]

Here is an example of configuring `pm.min_spare_servers` in the PHP-FPM pool configuration file (e.g., `www.conf`):

; Set the minimum number of spare (idle) servers
pm = dynamic
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.start_servers = 7
pm.max_children = 50

Explanation[편집 | 원본 편집]

  • `pm = dynamic`: Enables dynamic process management mode.
  • `pm.min_spare_servers = 5`: Ensures that at least 5 idle worker processes are maintained.
  • `pm.max_spare_servers = 10`: Limits the maximum number of idle worker processes to 10.

Applicability[편집 | 원본 편집]

The `pm.min_spare_servers` directive is useful in scenarios where:

  • There are sudden spikes in traffic that require immediate processing.
  • The server needs to balance resource usage by keeping idle workers available.

Advantages[편집 | 원본 편집]

  • Reduces response time by pre-allocating worker processes.
  • Helps manage server load dynamically without manual intervention.
  • Improves user experience during traffic surges.

Limitations[편집 | 원본 편집]

  • Setting too high a value can lead to unnecessary resource consumption (e.g., memory usage).
  • Does not apply to other process management modes like `static` or `ondemand`.

Related Directives[편집 | 원본 편집]

  • pm.max_spare_servers: Sets the maximum number of idle worker processes.
  • pm.start_servers: Defines the number of worker processes created on startup.
  • pm.max_children: Limits the total number of child processes.

See Also[편집 | 원본 편집]