Linux platform PHP5.4 How to set the number of FPM threads _php Tips

Source: Internet
Author: User
Tags fpm php programming

This example describes the Linux platform PHP5.4 How to set the number of FPM threads. Share to everyone for your reference, specific as follows:

After the PHP5.4 is installed, the default profile for FPM is located in/usr/local/php/etc/php-fpm.conf.default

>cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
>vim/usr/local/php/etc/ Php-fpm.conf

Enter "/www" to search the pool at www

PM = dynamic; The number of child processes to being created when PM is set to ' static ' and ';
Maximum number of child processes when the PM is set to ' dynamic ' or ' OnDemand '. ; This value sets the limit on the number of simultaneous requests that would be; Served.
Equivalent to the apachemaxclients directive with Mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP; Cgi. The below defaults are based on a server without much of the resources. Don ' t;
Forget to tweak pm.* to fit your needs. ; note:used when PM are set to ' static ', ' dynamic ' or ' OnDemand ';
Note:this value is mandatory. Pm.max_children = 5;
The number of child processes created on startup. ; Note:used only if PM is set to ' dynamic '; Default value:min_spare_servers + (max_spare_servers-min_spare_servers)/2 pm.start_servers = 2;
The desired minimum number of idle server processes. ; Note:used only if PM is set to ' dynamic '; Note:mandatory when PM are set to ' dynamic ' pm.min_spAre_servers = 1;
The desired maximum number of idle server processes. ; Note:used only if PM is set to ' dynamic '; Note:mandatory when PM are set to ' dynamic ' pm.max_spare_servers = 3;
The number of seconds after which a idle process would be killed. ; note:used only when the PM is set to ' OnDemand '; Default value:10s;p m.process_idle_timeout = 10s;;
The number of requests each child process should execute before respawning. ; This can is useful to work around memory leaks at 3rd party libraries. for; Endless request processing Specify ' 0 '.
Equivalent to Php_fcgi_max_requests. ;

 Default value:0;p m.max_requests = 500

Explain:

PM = How dynamic controls the subprocess, the options are static and dynamic, the default is dynamic, and if you choose Static, the number of fixed Pm.max_children is specified by the.

If dynamic is selected, it is determined by the following parameters:

Pm.max_children Maximum number of child processes
Pm.start_servers Number of processes at startup
Pm.min_spare_servers Guarantees the minimum number of idle processes, and creates a new child process if the idle process is less than this value
Pm.max_spare_servers The maximum number of idle processes is guaranteed, and cleanup is done if the idle process is greater than this value. For dedicated servers, PM can be set to static.
Pm.max_requests Sets the number of requests for services before each subprocess is reborn. is useful for Third-party modules that may have memory leaks. If set to ' 0′, the request is always accepted. Set to 500 is OK (default 0).

Modify the value to read as follows:

Pm.max_children =
Pm.start_servers =
pm.min_spare_servers = 8
pm.max_spare_servers =
pm.max_ Requests = 500

: Wq Save quit Vim

>/usr/local/php/sbin/php-fpm-t
notice:configuration file/usr/local/php/etc/php-fpm.conf test is successful

Test configuration file is normal, no problem, kill the current FPM process

>/usr/local/php/sbin/php-fpm

Start

More about PHP Interested readers can view the site topics: "PHP Design Security Course", "PHP object-oriented Program Design Introductory Course", "PHP Mathematical Calculation Skills Summary", "PHP Array" Operation Techniques Encyclopedia, "PHP string (String) Usage summary, "PHP Data structure and algorithm tutorial", "PHP Programming algorithm Summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

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.