最近 Apache 一直在生成 worker,尽管这似乎毫无理由。重启约 10 分钟后,它会不断生成 worker,直到达到最大数量,并且永远不会处理新的请求。
服务重启后(service apache2 restart
)我开始监控访问日志。在它开始疯狂生成 worker 之前,只有两个相当简单的请求:
#/var/log/apache2/access.log
66.249.64.215 - - [17/Feb/2016:00:30:18 +0000] "GET /wp-content/uploads/2015/08/colarinho_3.png HTTP/1.1" 304 179 "-" "Googlebot-Image/1.0"
201.80.103.196 - - [17/Feb/2016:00:33:00 +0000] "GET /wp-content/uploads/2015/09/circulo_cromatico.png HTTP/1.1" 200 40642 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0"
这是完全停止处理新请求之前的完整状态。
$apache2ctl fullstatus
Apache Server Status for localhost (via ::1)
Server Version: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.12
Server MPM: prefork
Server Built: Jul 24 2015 17:25:11
__________________________________________________________________
Current Time: Wednesday, 17-Feb-2016 00:35:57 UTC
Restart Time: Wednesday, 17-Feb-2016 00:26:33 UTC
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 9 minutes 24 seconds
Server load: 0.00 0.06 0.18
Total accesses: 3 - Total Traffic: 48 kB
CPU Usage: u0 s0 cu0 cs0
.00532 requests/sec - 87 B/second - 16.0 kB/request
22 requests currently being processed, 4 idle workers
WWWWWWWWWWWWWWWWWWWW_WW___........................
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 6980 0/0/0 W 0.00 64 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/191.185.144.200 HTTP/1.0
1-0 6981 0/1/1 W 0.00 55 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
2-0 6982 0/1/1 W 0.00 52 0 0.0 0.04 0.04 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
3-0 6983 0/0/0 W 0.00 65 0 0.0 0.00 0.00 191.185.144.200
socialtailor.com.br:80 GET / HTTP/1.1
4-0 6984 0/0/0 W 0.00 64 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
5-0 6989 0/0/0 W 0.00 55 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
6-0 6990 0/0/0 W 0.00 50 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
7-0 6991 0/0/0 W 0.00 41 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
8-0 6992 0/0/0 W 0.00 50 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
9-0 6993 0/0/0 W 0.00 40 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
10-0 6994 0/0/0 W 0.00 38 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
11-0 6995 0/0/0 W 0.00 35 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
12-0 6996 0/0/0 W 0.00 24 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
13-0 6997 0/0/0 W 0.00 32 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
14-0 6998 0/0/0 W 0.00 24 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
15-0 6999 0/0/0 W 0.00 24 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
16-0 7000 0/0/0 W 0.00 11 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
17-0 7001 0/0/0 W 0.00 7 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
18-0 7002 0/0/0 W 0.00 7 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
19-0 7003 0/0/0 W 0.00 4 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
20-0 7004 0/1/1 _ 0.00 7 0 0.0 0.01 0.01 ::1 socialtailor.com.br:80 GET
/server-status HTTP/1.0
21-0 7005 0/0/0 W 0.00 2 0 0.0 0.00 0.00 127.0.0.1
socialtailor.com.br:80 GET /lookup/127.0.0.1 HTTP/1.0
22-0 7006 0/0/0 W 0.00 0 0 0.0 0.00 0.00 ::1 socialtailor.com.br:80 GET
/server-status HTTP/1.0
__________________________________________________________________
Srv Child Server number - generation
PID OS process ID
Acc Number of accesses this connection / this child / this slot
M Mode of operation
CPU CPU usage, number of seconds
SS Seconds since beginning of most recent request
Req Milliseconds required to process most recent request
Conn Kilobytes transferred this connection
Child Megabytes transferred this child
Slot Total megabytes transferred this slot
__________________________________________________________________
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
它所服务的站点安装了 Wordpress。我将其更新到最新版本并禁用了 cron 作业。知道为什么会发生这种情况或如何进一步调试吗?
更奇怪的是:如果我这样做,lynx http://localhost/
它会一直等待响应(即使 Apache 没有超载工作人员),然后 Apache 会立即开始产生大量工作人员,就像以前一样。
我正在使用带有以下配置的 mpm_prefork:
#/etc/apache2/mods-enabled/mpm_prefork.conf
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 50
MaxConnectionsPerChild 1000
</IfModule>