I am testing why sometimes my PHP scripts takes long to load over network (>30sec) on my Apache 2.4 Ubuntu server with PHP-FPM 7.4 using mpm_event. The server was working normally in the past few months, this started happening a few days ago and I didn't change anything. I did a reboot, it didn't help.
I've made a simple test.php
. Sometimes it loads normally (<100ms), but sometimes it takes 1 minute to load:
<?php echo "test\n"; ?>
- Server's CPU, RAM and IO are all normal (checked with
htop
). - Static HTML files are loaded without any delays.
- Running script locally via SSH console is very fast.
- Apache error logs doesn't show anything unusual.
- I checked if there is some DDOS attack by checking the number of connected IPs from same /16 subnet and didn't find anything weird (e.g. >100 connections).
How can I debug this further to see why this is happening?
Some debug output which may help:
sudo service php7.4-fpm status
Best Answer
There may be several reasons for this behavior:
Log message:
is just proof of the increased load.
In both cases, you should determine the reasons for the load by analyzing the number of requests to the scripts, and if there are calls to external resources, make sure that they work correctly.