PHP-FPM (FastCGI Process Manager) plays an important role in improving the speed of the WordPress admin page. PHP-FPM can increase server performance by efficiently processing PHP requests, and can solve the problem of slow admin pages. we’ll walk you through how to change your PHP-FPM settings below.
when should you use PHP-FPM?
You should consider using PHP-FPM in the following situations
- high-traffic websites
- on high-traffic sites that need to handle thousands or more concurrent requests per day, PHP-FPM reduces bottlenecks and improves response times.
- server environments with limited resources
- Because PHP-FPM manages memory and CPU resources efficiently, it provides performance improvements even in limited server environments.
- when your WordPress admin page is slow
- admin pages generate more PHP requests than regular pages, so PHP-FPM optimizations can improve speed.
- When PHP requests are overloaded
- when your existing PHP settings can’t handle enough concurrent requests, resulting in a 504 Gateway Timeout error, applying PHP-FPM can fix the problem.
PHP-FPM Key Settings Explained and Recommended Values
To optimize the performance of PHP-FPM, we’ve summarized the important settings and recommended values below, each of which affects the performance of request handling for dynamic websites, such as the WordPress admin page.
name: 1️⃣ pm.max_children
- description
- defines the maximum number of requests that can be processed at the same time.
- Sets the maximum number of requests that PHP-FPM can handle at once, after which requests will be put into a queued state.
- this value is determined by the memory capacity of the server.
- recommended values
- 10-50: Small websites.
- 50-150: Medium traffic websites.
- 150-300: High-traffic websites.
- (For example, you can have about 20 max_children per 1 GB of RAM)
description: 2️⃣ pm.start_servers
- description
- The number of processes PHP-FPM prepares at startup.
- sets the number of processes that are ready and waiting to handle initial requests.
- a setting that is too low can increase the latency of initial requests.
- recommended value
- set between the values of
pm.min_spare_servers and
pm.max_spare_servers
- example)
If
pm.min_spare_servers=5 and
pm.max_spare_servers=10,
setpm.start_servers=7
.
- example)
- set between the values of
description: 3️⃣ pm.min_spare_servers
- description
- defines the minimum number of processes that should always be kept alive while waiting for requests.
- if there are fewer processes than this value, PHP-FPM will create a new process.
- recommended value
- small sites: 2-5
- high-traffic sites : 5-10
4️⃣ pm.max_spare_servers
- description
- defines the maximum number of processes that can be created to wait for requests.
- processes that exceed the set value will be eliminated.
- if this value is too high, it can cause memory waste.
- recommended value
- small sites: 5 to 10
- high-traffic sites : 10-20
5️⃣ pm.max_requests
- description
- sets the maximum number of requests that each PHP-FPM process can handle.
- this value serves to periodically recreate the process to prevent memory leaks.
- a value that is too low can cause performance degradation due to frequent process regeneration, while a value that is too high can cause problems due to memory leaks.
- recommended values
- 500 to 1000: Stable request processing.
- 1000 to 2000 ispossible onhigh-traffic websites ifthere are nomemory issues.
description: 6️⃣ pm=dynamic or static
- explanation
- How PHP-FPM processes are managed
- dynamic: dynamically increase/decrease processes based on the number of requests.
- static: Maintains a fixed number of processes.
- How PHP-FPM processes are managed
- recommended
- dynamic: Suitable for most sites.
- static: Sites that are very stable and require fixed resource allocation.
example final settings
here are some examples of settings based on your server memory and traffic situation
medium traffic (based on 4 GB of RAM)
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15
pm.max_requests = 1000
high Traffic (based on 8GB of RAM)
pm = dynamic
pm.max_children = 150
pm.start_servers = 20
pm.min_spare_servers = 15
pm.max_spare_servers = 30
pm.max_requests = 2000
How to optimize the admin page by changing PHP-FPM settings
1️⃣ Why you need PHP-FPM settings
- improving concurrent request handling
- PHP-FPM greatly improves the performance of dynamic websites like WordPress by managing multiple processes.
- increased resource efficiency
- PHP requests are handled efficiently, reducing CPU and memory usage.
- improved speed, especially for admin pages
- admin pages generate more PHP requests, so it’s important to optimize PHP-FPM’s performance.
2️⃣ Enable PHP-FPM and change the settings in your cPanel
- log in to your cPanel
- log in to your hosting management tool and navigate to the PHP Settings page.
- Activate PHP-FPM
- selectSoftware → MultiPHP Manager.
- Make sure PHP-FPM is enabled for the domain used for your WordPress site, and if it is not, click the Enable button.
- Change PHP-FPM settings
- goto Software → MultiPHP INI Editor.
- Adjust the PHP-FPM related settings as shown below:
setting Description:
pm.max_children
: Maximum number of requests that can be handled simultaneously. (The higher you set it, the more concurrent requests you can handle)- recommended value :
pm.start_servers
: Initial number of processes.pm.min_spare_servers
: Minimum number of standby processes.pm.max_spare_servers
: Maximum number of spare processes.pm.max_requests
: Maximum number of requests that one process can handle. (500 to 1000 is recommended)
pm = dynamic pm.max_children = 20 pm.start_servers = 4 pm.min_spare_servers = 2 pm.max_spare_servers = 8 pm.max_requests = 500
3️⃣ Modifying the PHP-FPM configuration file directly
if your hosting environment is not cPanel, you can connect to your server with SSH and modify the PHP-FPM configuration file directly.
- Open the PHP-FPM configuration file:
After connecting to the server via SSH, open the PHP-FPM configuration file. To open the PHP-FPM configuration file, open a shell and enter the code below.
sudo nano /etc/php/7.x/fpm/pool.d/www.conf
- modify the settings:
adjust the main items as below
pm = dynamic pm.max_children = 30 pm.start_servers = 5 pm.min_spare_servers = 3 pm.max_spare_servers = 10 pm.max_requests = 1000
- Restart PHP-FPM:
restart the PHP-FPM service after changing the settings.
sudo systemctl restart php7.x-fpm
4️⃣ Additional work to optimize the admin page
In addition to changing the PHP-FPM settings, to optimize your WordPress admin page speed, do the following tasks together
- Limit the Heartbeat API
- Install the Heartbeat Control plugin to limit the frequency of AJAX requests on the admin page.
- set up cache plugins
- Utilize cache plugins like WP Rocket and W3 Total Cache to improve admin page performance.
- optimize your database
- Use the WP-Optimize plugin to clean up outdated revisions, temporary data, and more.
- Upgrade your PHP version
- Using PHP 8.0 or higher will significantly improve performance.
check your PHP-FPM optimization results 5️⃣
- check site performance
- check if the admin page speed has improved.
- if necessary, analyze query processing times with the Query Monitor plugin.
- check server resource usage
- monitor CPU and memory usage in cPanel or your server management tool.
🚀 Conclusion
Properly tuning your PHP-FPM settings can significantly improve the speed of your WordPress admin page. additionally, limiting Heartbeat, cache optimization, database cleanup, etc. can have an even greater effect.
PHP-FPM is a PHP execution environment that improves both performance and resource management, and is especially useful for solving speed issues on high-traffic sites or WordPress admin pages. when set up correctly, it can dramatically improve your website’s performance and provide reliable service through efficient process management.
Let’s take a look at what PHP-FPM offers and how to set it up, then move on to specific steps to troubleshoot WordPress performance issues. 😊