High CPU and Memory PHP-FPM 7.2

December 30, 2018 2.8k views
PHP

Hello,

We are using a droplet with 4 GB Memory / 80 GB Disk / FRA1 - Ubuntu 18.10 x64. We have installed varnish, nginx 1.15.5, php 7.2. Mysql is hosted on another droplet. In droplet graphs php-fpm7.2 seems to use CPU 95% and Memory 46%. I have tried many configurations for php-fpm without fixing my problem.

Previously i had my droplet using php-fpm 7.0 and was working normally. Any suggestions please?

2 Answers
negrusti December 30, 2018
Accepted Answer

Hi,
For starters create separate php-fpm pools for each domain, and you will see in htop which domain creates the load. Then you will need PHP profiling to find the bottleneck in the code of this site.

Regards
Gregory

On my /etc/php/7.2/fpm/pool.d/www.conf we are having the following:

pm = dynamic
pm.maxchildren = 10
pm.start
servers = 4
pm.minspareservers = 2
pm.maxspareservers = 6
pm.max_requests = 500

Using top -c you can see high CPU usage (i cannot find a way to check which domain is each pid refer to):

9484 www-data 20 0 656060 397488 114020 S 56.5 9.8 3:02.52 php-fpm: pool www

9621 www-data 20 0 634516 362396 100496 S 34.6 9.0 1:08.24 php-fpm: pool www

9514 www-data 20 0 554140 283408 101936 S 19.3 7.0 2:58.73 php-fpm: pool www

9487 www-data 20 0 543668 271680 100692 S 17.6 6.7 2:52.57 php-fpm: pool www

1084 redis 20 0 971644 262836 2584 S 10.0 6.5 75:30.51 /usr/bin/redis-server 127.0.0.1:6379

9517 www-data 20 0 666512 395724 101900 R 2.0 9.8 2:28.29 php-fpm: pool www

Have another answer? Share your knowledge.