Apache-windows2003 apache占用cpu过高

发布于 2016-11-23 23:51:44 字数 4364 浏览 1356 评论 1

今天测试网站访问压力,没过一会就发现apache的占用率到达100%
查看错误日志发现如下错误:

[Sun Jan 12 18:06:26 2014] [notice] Apache/2.2.22 (Win32) PHP/5.3.21 configured -- resuming normal operations
[Sun Jan 12 18:06:26 2014] [notice] Server built: Jan 28 2012 11:16:39
[Sun Jan 12 18:06:26 2014] [notice] Parent: Created child process 1808
[Sun Jan 12 18:06:26 2014] [notice] Disabled use of AcceptEx() WinSock2 API
[Sun Jan 12 18:06:26 2014] [notice] Child 1808: Child process is running
[Sun Jan 12 18:06:27 2014] [notice] Child 2304: Released the start mutex
[Sun Jan 12 18:06:27 2014] [notice] Child 1808: Acquired the start mutex.
[Sun Jan 12 18:06:27 2014] [notice] Child 1808: Starting 150 worker threads.
[Sun Jan 12 18:06:27 2014] [notice] Child 1808: Listening on port 80.
[Sun Jan 12 18:06:33 2014] [notice] Child 2304: All worker threads have exited.
[Sun Jan 12 18:06:34 2014] [notice] Child 2304: Child process is exiting
[Sun Jan 12 18:11:44 2014] [notice] Child 1808: Process exiting because it reached MaxRequestsPerChild. Signaling the parent to restart a new child process.
[Sun Jan 12 18:11:44 2014] [notice] Parent: Received restart signal -- Restarting the server.
[Sun Jan 12 18:11:45 2014] [notice] Apache/2.2.22 (Win32) PHP/5.3.21 configured -- resuming normal operations
[Sun Jan 12 18:11:45 2014] [notice] Server built: Jan 28 2012 11:16:39
[Sun Jan 12 18:11:45 2014] [notice] Parent: Created child process 1716
[Sun Jan 12 18:11:45 2014] [notice] Disabled use of AcceptEx() WinSock2 API
[Sun Jan 12 18:11:45 2014] [notice] Child 1808: Released the start mutex
[Sun Jan 12 18:11:45 2014] [notice] Child 1716: Child process is running
[Sun Jan 12 18:11:45 2014] [notice] Child 1716: Acquired the start mutex.
[Sun Jan 12 18:11:45 2014] [notice] Child 1716: Starting 150 worker threads.
[Sun Jan 12 18:11:45 2014] [notice] Child 1716: Listening on port 80.
[Sun Jan 12 18:11:58 2014] [notice] Child 1808: All worker threads have exited.
[Sun Jan 12 18:11:59 2014] [notice] Child 1808: Child process is exiting
[Sun Jan 12 18:17:29 2014] [notice] Child 1716: Process exiting because it reached MaxRequestsPerChild. Signaling the parent to restart a new child process.
[Sun Jan 12 18:17:29 2014] [notice] Parent: Received restart signal -- Restarting the server.
[Sun Jan 12 18:17:30 2014] [notice] Apache/2.2.22 (Win32) PHP/5.3.21 configured -- resuming normal operations
[Sun Jan 12 18:17:30 2014] [notice] Server built: Jan 28 2012 11:16:39
[Sun Jan 12 18:17:30 2014] [notice] Parent: Created child process 1844
[Sun Jan 12 18:17:30 2014] [notice] Disabled use of AcceptEx() WinSock2 API
[Sun Jan 12 18:17:30 2014] [notice] Child 1716: Released the start mutex
[Sun Jan 12 18:17:31 2014] [notice] Child 1844: Child process is running
[Sun Jan 12 18:17:31 2014] [notice] Child 1844: Acquired the start mutex.
[Sun Jan 12 18:17:31 2014] [notice] Child 1844: Starting 150 worker threads.
[Sun Jan 12 18:17:31 2014] [notice] Child 1844: Listening on port 80.
[Sun Jan 12 18:17:47 2014] [notice] Child 1716: All worker threads have exited.
[Sun Jan 12 18:17:48 2014] [notice] Child 1716: Child process is exiting
[Sun Jan 12 18:39:59 2014] [notice] Child 1844: Process exiting because it reached MaxRequestsPerChild. Signaling the parent to restart a new child process.
[Sun Jan 12 18:39:59 2014] [notice] Parent: Received restart signal -- Restarting the server.
[Sun Jan 12 18:40:00 2014] [notice] Apache/2.2.22 (Win32) PHP/5.3.21 configured -- resuming normal operations
[Sun Jan 12 18:40:00 2014] [notice] Server built: Jan 28 2012 11:16:39
[Sun Jan 12 18:40:00 2014] [notice] Parent: Created child process 2280
[Sun Jan 12 18:40:00 2014] [notice] Disabled use of AcceptEx() WinSock2 API
[Sun Jan 12 18:40:00 2014] [notice] Child 2280: Child process is running
[Sun Jan 12 18:40:00 2014] [notice] Child 1844: Released the start mutex
[Sun Jan 12 18:40:00 2014] [notice] Child 2280: Acquired the start mutex.
[Sun Jan 12 18:40:00 2014] [notice] Child 2280: Starting 150 worker threads.
[Sun Jan 12 18:40:00 2014] [notice] Child 2280: Listening on port 80.
[Sun Jan 12 18:40:00 2014] [notice] Child 1844: All worker threads have exited.
[Sun Jan 12 18:40:02 2014] [notice] Child 1844: Child process is exiting

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虐人心 2017-03-18 22:59:07

没有太多这方面的经验, 仅供参考了.

http://httpd.apache.org/docs/current/platform/windows.html
apache在windows上仅有一个child进程. MaxRequestsPerChild是说child进程同时能处理的连接数, 超出后子进程会死掉.

所以你的log里的行为应该可以解释了, 可以看到一个子进程被起来, 然后连接数超出了MaxRequestsPerChild(你在做压力测试, 估计上了2000个连接了吧?), 死掉; 下一个子进程被起来, 死掉...

所以我觉得
1). 压力测试的强度不要超过MaxRequestsPerChild;
2). 按你们网站预期的连接数, 合理的配置MaxRequestsPerChild. 上面的文档里:
"Use the default MaxConnectionsPerChild 0, unless instructed to change the behavior to overcome a memory leak in third party modules or in-process applications." MaxRequestsPerChild设为0, 即无限制.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文