PHP-FPM pm.min_spare_servers Explained: Configuration, Idle Workers, and Best Practices
Introduction
The pm.min_spare_servers directive specifies the minimum number of idle worker processes that PHP-FPM should maintain when using the dynamic process manager.
Idle workers are ready to accept new requests immediately. If the number of idle workers falls below the configured minimum, PHP-FPM automatically creates additional workers until the minimum level is restored.
Properly configuring this setting helps reduce response latency during traffic spikes while avoiding unnecessary resource consumption.
This guide explains how pm.min_spare_servers works, how it interacts with other PHP-FPM directives, recommended values, and common configuration mistakes.
Test Environment
What Is pm.min_spare_servers?
When PHP-FPM runs in dynamic mode, some worker processes remain idle while waiting for new requests.
The pm.min_spare_servers directive defines the minimum number of idle workers PHP-FPM should keep available.
Example:
pm = dynamic
pm.min_spare_servers = 5
In this example, PHP-FPM always tries to keep at least five idle workers available.
How It Works
Assume the following configuration:
pm = dynamic
pm.min_spare_servers = 5
Initially:
PHP-FPM Pool
Traffic increases:
More requests arrive:
At this point, there are zero idle workers, which is below the configured minimum.
PHP-FPM automatically creates additional workers:
The idle worker count is restored without requiring a service restart.
Check the Current Value
Most Linux distributions store pool settings in:
/etc/php-fpm.d/www.conf
Run:
Example:
pm.min_spare_servers = 5
Change pm.min_spare_servers
Open the PHP-FPM pool configuration.
sudo nano /etc/php-fpm.d/www.conf
Locate:
pm.min_spare_servers = 5
Example:
pm.min_spare_servers = 10
Save the file.
Restart PHP-FPM
Apply the changes.
sudo systemctl restart php-fpm
Verify:
sudo systemctl status php-fpm
Expected output:
Active: active (running)
Relationship with Other PHP-FPM Settings
pm.min_spare_servers works together with several other process manager directives.
Each setting has a different responsibility.
Example Configuration
pm = dynamic
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 12
pm.max_children = 40
Behavior:
PHP-FPM starts with 8 workers.
If idle workers fall below 4, new workers are created.
If idle workers exceed 12, extra idle workers are terminated.
The total number of workers never exceeds 40.
Recommended Values
These values should always be adjusted according to available memory and expected traffic.
Common Issues
Too Few Idle Workers
Example:
pm.min_spare_servers = 1
When traffic suddenly increases, PHP-FPM must create new workers before processing all requests.
This may slightly increase response time during traffic spikes.
Too Many Idle Workers
Example:
pm.min_spare_servers = 30
If traffic is low, many workers remain idle while still consuming memory.
This reduces the amount of RAM available for other services such as MySQL, Redis, or the operating system.
Configuration Error
A common mistake is configuring:
pm.start_servers = 3
pm.min_spare_servers = 8
This is inconsistent because PHP-FPM starts with fewer workers than the configured minimum idle requirement.
A more reasonable configuration would be:
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
The startup value should generally fall between the minimum and maximum idle worker limits.
Best Practices
Use pm.min_spare_servers only when pm = dynamic.
Configure enough idle workers to handle normal traffic without excessive process creation.
Avoid reserving large numbers of idle workers on low-memory servers.
Keep pm.start_servers, pm.min_spare_servers, and pm.max_spare_servers logically consistent.
Monitor worker activity and memory usage before making significant adjustments.
Conclusion
The pm.min_spare_servers directive controls the minimum number of idle PHP-FPM worker processes maintained in dynamic mode. By ensuring that idle workers are always available, PHP-FPM can respond more quickly to incoming requests while automatically scaling the worker pool as demand changes.
Rather than tuning this directive in isolation, it should be configured together with pm.start_servers, pm.max_spare_servers, and pm.max_children to achieve a balanced combination of performance, responsiveness, and efficient memory usage.
Explore More
› PHP-FPM pm.max_spare_servers Explained: Configuration, Idle Worker Limits, and Best Practices
› PHP-FPM pm.max_children Explained: Configuration, Performance, and Best Practices
› PHP-FPM pm.max_requests Explained: Configuration, Memory Management, and Best Practices
› PHP-FPM pm.start_servers Explained: Configuration, Worker Management, and Best Practices
› Best Coworking Spaces in Bangkok 2026: A Guide for Digital Nomads and Remote Workers
› Best Areas to Live in Bangkok in 2026: A Complete Guide for Expats and Digital Nomads
› Why Do People in Southeast Asia Love Iced Drinks? The Climate, Culture, and Science Explained
› Best eSIM for Southeast Asia in 2026: Compare the Top Travel eSIMs