How to track why php-fpm is using too much CPU

Viewed 223

I am using Ubuntu 18.04 with PHP application and Mysql server on it. Usually application is working fine and I am having Load average of 1.0-2.0 on my 48 Cores CPU. However, in some moments suddently I am getting a lot of CPU usage from PHP-FPM, it jumps from 1.0 Load Average to 8.0 Load Average:

PID    USER    PRI    VIRT    RES     SHR      S      CPU         MEM%   COMMAND

124    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
125    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
126    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
127    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
128    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
129    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www
130    megax    20    335M    19254   21212    S      100.00%      0.0   php-fpm: pool www

Is there any way I can troubleshoot this why it suddenly becomes crazy and increase CPU usage by 700%?

thanks

1 Answers

You will need to profile your PHP code to establish what part of it is burning all that CPU. You can do this using a PHP code profiler, such as Xdebug.

Related