尽管页面生成速度非常快,但 Apache Mod 状态下的 CPU 秒数值非常高

尽管页面生成速度非常快,但 Apache Mod 状态下的 CPU 秒数值非常高

我们有一个 VPS,上面有几个网站。最近几天,它负载过大,有时甚至停止响应,不得不重新启动。

经过调查,我们发现 apache 的 CPU 使用率似乎很高。我们现在正在查看 mod_status 的统计数据以查找问题根源。

下面是一个例子。

对我们来说似乎不合理的是某些页面上的 CPU 值较高。例如 results.42km.ro:80 GET /athletes/view?id=13115 HTTP/1.1 上的 CPU 值为 28.17

在 CPU 列的说明中,它显示了 CPU 使用率、秒数,这是否意味着该过程花费了 28 秒?

Current Time: Friday, 15-May-2015 12:49:54 EEST
Restart Time: Friday, 15-May-2015 12:27:35 EEST
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 22 minutes 18 seconds
Server load: 2.09 2.92 2.98
Total accesses: 2556 - Total Traffic: 52.6 MB
CPU Usage: u199.9 s33.2 cu0 cs0 - 17.4% CPU load
1.91 requests/sec - 40.2 kB/second - 21.1 kB/request
2 requests currently being processed, 4 idle workers

.___W.._C.....................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

Srv PID Acc M   CPU     SS  Req Conn    Child   Slot    Client  VHost   Request
0-0 -   0/0/363 .   19.73   88  0   0.0 0.00    7.11    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
1-0 16963   0/25/222    _   6.89    2   140 0.0 0.71    4.63    66.249.78.68    results.42km.ro:80  GET /athletes/view?id=14633 HTTP/1.1
2-0 14797   0/213/351   _   28.17   1   113 0.0 3.59    6.25    37.140.141.38   results.42km.ro:80  GET /athletes/view?id=13115 HTTP/1.1
3-0 15585   0/177/305   _   26.38   0   235 0.0 3.33    5.63    82.210.155.128  _wildcard_.galantom.ro:80   GET /tiberiulupu2 HTTP/1.1
4-0 15595   0/184/293   W   27.70   0   0   0.0 7.68    9.08    127.0.0.1   vps.server777.ro:80 GET /whm-server-status/ HTTP/1.0
5-0 -   0/0/82  .   1.47    549 0   0.0 0.00    2.80    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
6-0 -   0/0/100 .   0.00    566 0   0.0 0.00    1.39    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
7-0 13690   0/307/307   _   47.44   2   209 0.0 5.97    5.97    109.166.141.79      
8-0 15605   1/166/177   C   28.79   0   260 8.6 3.74    3.82    157.55.39.91    results.42km.ro:80  GET /results/view?id=141538 HTTP/1.1
9-0 -   0/0/7   .   0.00    565 0   0.0 0.00    0.05    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
10-0    -   0/0/123 .   20.39   560 0   0.0 0.00    1.99    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
11-0    -   0/0/97  .   3.38    457 0   0.0 0.00    1.71    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0
12-0    -   0/0/129 .   22.76   559 0   0.0 0.00    2.14    ::1 vps.server777.ro:443    OPTIONS * HTTP/1.0

答案1

我曾经看到过这种情况,当 MySQL 服务器似乎响应缓慢时,会导致进程锁定,从而在等待时耗尽 CPU,因此值得在 SQL 遇到困难时查看一下它,看看这是否是真正的原因。

相关内容