Question

High CPU and Memory PHP-FPM 7.2

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?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.max_children = 10 pm.start_servers = 4 pm.min_spare_servers = 2 pm.max_spare_servers = 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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.