Highly Recommended Performance Pool | StudyObject

Don't Miss ! Understand the exact setting needed for your server

We are going to discuss amazing PHP-FPM pool , FPM stands for Fast CGI(Common gateway Interface) Process Manager and maintains different pool of child processes for different portals. We will provide exact setting to fine tune your server.

Try following PHP-FPM pool setting ! It is not less than gold !

PHP-FPM

PHP-FPM is an advance PHP FastCGI designed for heavy loaded sites. We will go through some of the important tips on PHP-FPM which will supercharge your portal.

What is the role of PHP-FPM

We know that images, css and js are directly served to Apache on any web request. PHP-FPM module of php are used for php files. So PHP-FPM pool plays a critical role in php processing and boosting performance. Your website uses php scripts in backend to do lot of useful operations like db query, plugin activity and other features.

We will discuss some interesting PHP-FPM directives which if handled properly can result in big performance boost and will supercharge your website.

Remember for now !

max_requests directive defines the no of php requests handled by a single child process.

Understanding static, dynamic & ondemand 

Let’s understand each of these important directives.

static – a fixed number (pm.max_children) of child processes;

dynamic – the number of child processes are set dynamically based on the following directives.

With dynamic type, there will always be at least 1 children.

pm.max_children – the maximum number of children that can be alive at the same time.
pm.start_servers – the number of children created on startup.
pm.min_spare_servers – the minimum number of children in ‘idle’ state (waiting to process). If the number of ‘idle’ processes is less than this number then some children will be created.
pm.max_spare_servers – the maximum number of children in ‘idle’ state (waiting to process). If the number of ‘idle’ processes is greater than this number then some children will be killed.

ondemand – no children are created at startup. Children will be forked when new requests will connect. The following parameter are used:

pm.max_children – the maximum number of children that can be alive at the same time.

pm.process_idle_timeout – The number of seconds after which an idle process will be killed.

Understand the directive max_request

 

pm.max_requests    //The number of requests each child process should execute before respawning

 

Don’t Miss ! Understand the exact setting needed for your server

Let’s Assume your server has 4 core 8 thread. I suggest to use dynamic type to have more control over CPU. To utilise the CPU properly you can define following

pm.min_spare_servers = 1

pm.max_spare_servers = 7

Usually default value of pm.start_servers is min_spare_servers + (max_spare_servers – min_spare_servers) / 2

pm.start_servers = 4     // 4 no of children will be started

pm.max_children = 8   // the maximum no of children which can be alive is 8.

pm.max_requests = 500;

//The number of requests each child process should execute before respawning , before setting high no like 500 check how much CPU your Single Page takes, each page gets loaded based on no of php requests. The pages having less php requests will consume less CPU and vice versa.

Above configuration will utilise four cores and 8 cpu threads properly. If you have more cores, adjust these value accordingly.

Golden Rule

 

These values are set per pool ( PHP-FPM ) per portal, So if multiple websites are located on same server then make sure to adjust accordingly.

 

Have you optimised PHP FPM pool? Try these, you will see a big performance boost ! Do not forget to share your experience !

 

 

Author: Rajnish K

About Author :

Rajnishk is R&D Expert ,passionate for Web Stack. He can be reached at info@studyobject.co

 

StudyObject © 2020. All rights reserved.
X