Welcome! Log In Create A New Profile

Advanced

php-fpm high cpu usage

Posted by khav 
php-fpm high cpu usage
September 18, 2014 05:36AM
I have a high traffic site (we are talking about millions of pageviews per month here) and i am having trouble optimizing php-fpm as each process is using a huge amount of cpu(15% to 99%).My load average is typically 20 at peak times (which is huge).



http://gyazo.com/866d574730def373e6c79e074fd52fcd

My server specs(i upgraded both ram and cpu in an attempt to solve the problem).My site uses just Nginx+PHP-FPM , there is no database or anything else but i use Zend Opcache

nginx version: nginx/1.7.5
PHP 5.5.16 (cli) (built: Sep 3 2014 20:08:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

Dual Xeon E5-2620
16gb of ram

I have many such warning in my logs

WARNING: [pool www] child 15215 exited on signal 15 (SIGTERM) after 319.786619 seconds from start

WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 76 idle, and 338 total children

My php-fpm config

pm = dynamic
pm.max_children = 800
pm.start_servers = 120
pm.min_spare_servers = 80
pm.max_spare_servers = 160
pm.max_requests = 500
Re: php-fpm high cpu usage
February 02, 2018 01:25PM
check how many php-fpm child processes are running with ram usage.

check amount of free memory by free -m or top or htop

2 gb for systemt

every prcoess using 100Mb ram


14000/100= 140

pm.max_children =140

you said 800, is 800 child proceesses are running?


pm start servers =
min_spare_servers + (max_spare_servers - min_spare_servers) / 2.


80+(160-80)/2= 120


incresethse values and reload php-fpm withoiut downtime

pm.start_servers = 120
pm.min_spare_servers = 80
pm.max_spare_servers = 160


check log do the sam untill error stops
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready