How to eliminate the problem of PHP-FPM service hanging out in Linux

Source: Internet
Author: User

Today sent a link, may be at the same time online more people, the results of 503 errors, back to open PHP-FPM error log a look, PHP-FPM service hung up, reported the following error:

[04-apr-2016 15:38:04] NOTICE:SYSTEMD monitor interval set to 10000MS
[05-apr-2016 19:03:08] WARNING: [Pool www] seems busy (you'll need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 Childr En, there are 0 idle, and total children
[05-apr-2016 19:03:09] WARNING: [Pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning Ren, there are 0 idle, and total children
[05-apr-2016 19:03:11] WARNING: [Pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning Ren, there are 0 idle, and total children
[05-apr-2016 19:03:12] WARNING: [Pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning Ren, there are 0 idle, and total children
[05-apr-2016 19:03:13] WARNING: [Pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning Ren, there are 0 idle, and total children
[05-apr-2016 19:03:14] WARNING: [Pool www] server reached Pm.max_children setting (m), consider raising it

Error tips suggest increasing the number of pm.start_servers and opening my PHP-FPM configuration:

Pm.max_children = 50

; 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 = 15

; 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 = 5

; 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 = 35

Here pm.start_servers before I set to 5, note that the configuration file also indicates that start_servers value defaults to max_spare_servers-min_spare_servers half. (PS: The specific values are based on server configuration and stress testing)

Web server is Aliyun 1G bandwidth, 1G memory, 1 Core CPU configuration, the key is also installed in a computer database, redis a variety of services.

Several php-fpm important parameter explanation

Shell

1
Pm.max_children = 24

The number of child processes created in static mode or the maximum number of php-fpm that are allowed at the same time in dynamic mode

Pm.start_servers = 16

Number of starting PHP-FPM processes in dynamic mode


Pm.min_spare_servers = 12

The minimum number of php-fpm processes in a dynamic way when the server is idle


Pm.max_spare_servers = 24

The maximum number of php-fpm processes in a dynamic way when the server is idle

The summary of the experience Person:

The general PHP-FPM process consumes about 20~30m memory by 30m. If run PHP-FPM alone, dynamic mode start value can set physical memory mem/30m, because everybody general nginx, MySQL all in a machine, so reserve half to them, namely PHP-FPM process number is $MEM/2/30.
Several values after the adjustment are:


PM = dynamic
Pm.max_children = 50
Pm.start_servers = 15
Pm.min_spare_servers = 10
Pm.max_spare_servers = 40

Restart PHP-FPM Services: Service PHP70-PHP-FPM Reload, continue to use the top command to view memory usage, and found more than 10 php-fpm started.

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.