Web 服务器 CPU 使用率高且响应缓慢

Web 服务器 CPU 使用率高且响应缓慢

我想找到 Web 服务器的瓶颈(运行在 32GB RAM/24 核上)启用 HT请参阅 Apache/mod_php)。

以下是我的观察,

  1. 内存似乎不是问题(只有 10MB 的交换空间)
  2. 提供静态内容的速度非常慢
  3. php 性能看起来不错(页面加载时间不到一秒)
  4. CPU 使用率高,有时 SYS 百分比会急剧上升(如下所示)

我猜第一步应该是在 apache 前面使用 ngnix 来提供静态内容?

或者 MPM-worker apache 和 php-fpm 作为替代方案怎么样?请提出建议并帮助我改进这个问题。


top - 11:22:54 up 170 days,  2:35,  6 users,  load average: 324.55, 210.85, 105.87
Tasks: 1351 total, 353 running, 990 sleeping,   7 stopped,   1 zombie
Cpu0  :  0.9%us, 98.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  1.1%si,  0.0%st
Cpu1  :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  3.7%us, 96.3%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :  2.8%us, 97.2%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu4  :  3.4%us, 96.6%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu5  :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu6  :  0.0%us, 99.1%sy,  0.9%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu7  :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu8  :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu9  :  6.6%us, 93.4%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu10 :  0.6%us, 99.4%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu11 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu12 :  6.6%us, 92.9%sy,  0.6%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu13 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu14 :  0.6%us, 99.4%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu15 :  0.3%us, 99.7%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu16 :  8.5%us, 91.5%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu17 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu18 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu19 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu20 :  6.3%us, 93.7%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu21 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu22 :  4.5%us, 95.5%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu23 :  0.0%us,100.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  32869868k total, 22865280k used, 10004588k free,   177048k buffers
Swap:  4194296k total,   104016k used,  4090280k free,  3578260k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 6736 apache    20   0  371m  59m 3724 R  7.6  0.2   0:28.97 httpd
 6868 apache    20   0  362m  45m 3756 R  7.6  0.1   0:23.53 httpd
  384 apache    20   0  350m  39m 3692 R  7.3  0.1   0:13.44 httpd
  488 apache    20   0  340m  32m 3848 R  7.3  0.1   0:15.58 httpd
  508 apache    20   0  328m  22m 4156 R  7.3  0.1   0:47.30 httpd
  731 apache    20   0  330m  22m 3852 R  7.3  0.1   0:42.05 httpd
 1028 apache    20   0  360m  48m 4168 R  7.3  0.2   0:45.40 httpd
 1113 apache    20   0  365m  58m 4168 R  7.3  0.2   0:28.10 httpd
 1197 apache    20   0  340m  34m 4156 R  7.3  0.1   0:38.98 httpd
 1373 apache    20   0  364m  59m 4860 R  7.3  0.2   0:36.98 httpd

[Sat Feb 22 09:40:25 2014] [notice] child pid 23674 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:01 2014] [notice] child pid 24974 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:03 2014] [notice] child pid 5107 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:06 2014] [notice] child pid 23932 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:06 2014] [notice] child pid 486 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:07 2014] [notice] child pid 5269 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:10 2014] [notice] child pid 2391 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:10 2014] [notice] child pid 5295 exit signal Segmentation fault (11)
[Sat Feb 22 11:15:15 2014] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Sat Feb 22 11:23:46 2014] [warn] child process 27887 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:46 2014] [warn] child process 5260 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:46 2014] [warn] child process 6713 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:48 2014] [warn] child process 27887 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:48 2014] [warn] child process 5260 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:48 2014] [warn] child process 6713 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:50 2014] [warn] child process 27887 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:50 2014] [warn] child process 5260 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:50 2014] [warn] child process 6713 still did not exit, sending a SIGTERM
[Sat Feb 22 11:23:52 2014] [error] child process 27887 still did not exit, sending a SIGKILL
[Sat Feb 22 11:23:52 2014] [error] child process 5260 still did not exit, sending a SIGKILL
[Sat Feb 22 11:23:52 2014] [error] child process 6713 still did not exit, sending a SIGKILL

相关内容