大网数据广告活动
服务器运维问答

PHP scripts suddenly load very slow on Apache

· 52CE 我爱测

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 …

问题原文

原帖链接 · c0dehunter · CC BY-SA 4.0

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

已采纳解答

原帖链接 · c0dehunter · CC BY-SA 4.0

I think I've found solution, but still if you have any suggestions please let me know or post another answer.

I checked /var/log/php7.4-fpm.log and saw this many entries like this:

[30-Sep-2021 03:36:46] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

So I raised the max_children to 15 and it seems it helps.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-09-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。