Okay, so readers, in this post we are going to study the PHP-FMP’s and how to maximize the performance tuning “pm statics”. We are going to see how to set PHP-FMP for high performance, low latency and more accurate use of CPU and memory. Originally, most of the PHP-FMP PM strings are set to dynamic and there also the device is available ondemand if memory failure situation comes.
Well, before jumping to the all-time favorite management option static pm, let’s compare all the management options available according to php.net documentation:
- pm = dynamic: In this management option, number of child processor is set dynamically using following directives; pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers.
- pm = ondemand: The process starts when the spawn of the request is made, mainly when dynamic opposed. Whereas process pm.start_servers are starts at the beginning of the service.
- pm = static: This process is fixed by the pm.max_children.
PHP-FMP Process Manager In Context of CPUFreq Governor
Well, we are going a bit off the topic here, but fellas PHP-FMP PM has similarities with the CPU frequency governor. Guys, we all have suffered from the low-performance issue of the CPU, once in our like whether we are working on a laptop, VM or dedicated server. And, only CPU frequency scaling can help you out here.
But, the problem of low CPU performance can be easily fixed using CPUFreq Governor setting. These sets are available in both the *nix and Windows. You can easily improve the performance and system response by changing the CPU governor setting from ondemand to the performance. Now, let’s find out some similarities between the different settings:
- Governor = ondemand: It scales down CPU frequency dynamically according to the current load. It first jumps directly to the higher frequency and then tunes down as per the time increase.
- Governor = conservative: It also scales down the CPU frequency as per current load, but it dies more gradually than ondemand.
- Governor = performance: Always sets CPU frequency to the optimum performance level.
So, you see people, when we set CPU governor setting, then the performance setting is pretty boosted as CPU limit depends on your device. Some factors like heat, battery life (laptop) and other side effects of clocking your CPU frequency to 100% permanently. But, once the setting is set to the performance, then indeed your CPU works fast.
Enhance Performance Using PM Static
Firstly, if you want to boost the performance using pm static, then you need free server space. And, if you don’t have any free memory, then you should use pm ondemand or dynamic. But, if you have free memory, then you should definitely use pm static. The pm.static should be set to the max amount of PHP-FPM processes that can run without creating memory availability or cache pressure issues. Also, not so high as to overwhelm CPU(s) and have a pile of pending PHP-FPM operations.
When To Use The PM Ondemand & Dynamic
Well, as we have studied when to use pm static, that’s why not let’s focus a little bit on pm ondemand and dynamic. Because in some cases, they are better than the pm static. For example, when you have multiple cPanel accounts or website accounts under different pools. It is impossible for pm static or even dynamic to perform in this kind of situation.
Whereas ondemand works totally as one-third of the website won’t receive any kind of traffic. And with ondemand, it means all children will be shut down saving tons of server memory! But, thankfully, PHP has understood this and changed default dynamic settings to the on-demand.
In the PHP-FM framework, once you start to receive some serious traffic, then both ondemand and dynamic won’t be enough due to their inherent overload. So, in that case, using pm.max_children set your PJP-FMP server to the maximum capacity matching your server. You will notice that with pm static because you keep everything sitting in memory, traffic spikes over time cause fewer spikes to CPU and your server’s load and CPU averages will be smoother.
So, in short, if you have a high traffic generating site, then you should move to the pm static.