I am observing the high CPU usage without any web traffic and the same websites.
and after that I paste ps aux|grep 352338
can you advise what I should do?
I am observing the high CPU usage without any web traffic and the same websites.
and after that I paste ps aux|grep 352338
can you advise what I should do?
aaP_siru.khan
Hello! It seems that an application is calling php-fpm, causing your CPU usage to spike. You can try checking which programs are accessing your PHP. If you confirm that nothing is calling it, we recommend disabling or restarting this PHP instance.
aaPanel_Jose How to check which program is using high php-fpm?
aaP_siru.khan
To check which program or script is consuming high resources in PHP-FPM, follow these methods:
top
or htop
Run the following command to see the CPU and memory usage of PHP-FPM processes:
top -u www-data
or (if htop
is installed):
htop
Look for processes running under the PHP-FPM user (usually www-data
, php-fpm
, or nginx
).
ps
Use ps
to check the most resource-consuming PHP-FPM processes:
ps aux --sort=-%cpu | grep php-fpm
or
ps aux --sort=-%mem | grep php-fpm
This will list PHP-FPM processes sorted by CPU or memory usage.
If a specific PHP script is consuming resources, enable the slow log:
Open your PHP-FPM pool configuration:
sudo nano /etc/php/{your_php_version}/fpm/pool.d/www.conf
Example: for PHP 8.1:
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
Find and set the following values:
slowlog = /var/log/php-fpm/slow.log
request_slowlog_timeout = 5s
Restart PHP-FPM:
sudo systemctl restart php-fpm
View the slow log:
cat /var/log/php-fpm/slow.log
This will show which scripts take longer than 5 seconds to execute.
lsof
To find which script is being executed by a PHP-FPM process, first get the process ID (PID) from top
or htop
, then run:
lsof -p <PID>
This will show which files the process is accessing, including the PHP script.
Use strace
to attach to a PHP-FPM worker and see what it's doing:
strace -p <PHP-FPM-PID>
This will show system calls made by the process, helping you identify what it's working on.
Check the PHP-FPM access log to see which scripts are being executed frequently:
tail -f /var/log/php-fpm.log
or, if using Nginx:
tail -f /var/log/nginx/access.log
ngrep
to Capture Real-Time RequestsIf you suspect a specific request is causing high PHP-FPM load, use ngrep
:
sudo ngrep -d any -W byline port 80 or port 443
This will capture incoming HTTP requests and help you identify problematic URLs.
top
/htop
to identify high-resource PHP-FPM processes.ps
to sort processes by CPU/memory usage.lsof
and strace
to inspect what a PHP-FPM process is doing.php-fpm.log
, nginx/access.log
) for frequently executed scripts.