Two kinds of process management modes in depth php-fpm _php tutorial

Source: Internet
Author: User
Tags vps
Two kinds of process management modes of PHP-FPM
The number of PHP-FPM processes can also be divided according to the settings Dynamic and StaticOf
One is to directly open the specified number of PHP-FPM processes, no longer increase or decrease;
The other is to start a certain number of php-fpm process, when the request is large, dynamically increase the number of PHP-FPM processes to the upper limit, when idle time automatically frees up the number of idle processes to a lower limit.
These two different execution modes can be adjusted according to the actual needs of the server.
Here are some of the parameters that relate to this, they are pm, Pm.max_children, Pm.start_servers, Pm.min_spare_servers and Pm.max_spare_servers respectively.
PM means that there are two values that can be selected, either static or dynamic, in that way.
in older versions, dynamic is called Apache-like. This should pay attention to the instructions given in the configuration file. PHP5.3
The default static processing of the PHP-FPM causes the php-cgi process to consume memory for a long time and cannot be released, which is one of the reasons for Nginx error, so you can change the way php-fpm is handled to Apache mode.
the meanings of the following 4 parameters are:
Pm.max_children: The number of PHP-FPM processes that are open in static mode.
Pm.start_servers: The number of start PHP-FPM processes under dynamic mode.
Pm.min_spare_servers: The minimum number of PHP-FPM processes under dynamic mode.
Pm.max_spare_servers: The maximum number of PHP-FPM processes under dynamic mode.
If the DM is set to static, then only pm.max_children this parameter takes effect. The system turns on the set number of PHP-FPM processes.

If the DM is set to dynamic, then the Pm.max_children parameter is invalidated and the next 3 parameters take effect. The system starts the Pm.start_servers PHP-FPM process at the beginning of the PHP-FPM run and then dynamically pm.min_spare_servers and Pm.max_spare_ according to the system's requirements Adjusts the number of PHP-FPM processes between servers.

So, for our server, which method of execution is better? In fact, like Apache, we run a PHP program after the completion of execution, more or less there is a memory leak problem.

This is why the beginning of a PHP-FPM process only consumes about 3M of memory, running for a period of time will rise to 20-30m reason. Therefore, the dynamic mode because it will end the redundant process, can be reclaimed to release some memory, so it is recommended to use on the server or VPS with less memory. The specific maximum number is based on the memory/20m. For example, 512M VPS, recommended pm.max_spare_servers set to 20. As for Pm.min_spare_servers, it is recommended to set the load on the server and compare the appropriate values between 5~10.

Then, for servers that are larger in memory, it is more efficient to set to static. Because the frequent switch PHP-FPM process will also sometimes lag, so the memory is large enough to open the static effect will be better. The quantity can also be obtained according to the memory/30m. For example, 2GB memory server, can be set to 50;4GB memory can be set to 100 and so on.

http://www.bkjia.com/PHPjc/327224.html www.bkjia.com true http://www.bkjia.com/PHPjc/327224.html techarticle PHP-FPM's two process management modes PHP-FPM The number of processes can be divided into dynamic and static according to the settings. One is to directly open the specified number of PHP-FPM processes, no longer increase or decrease ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.