我编写了一个RESTful Web服务,作为使用PHP和Restler库的移动应用程序的支柱。 它运行在运行Windows Server 2008 R2,PHP 5.3.5,Apache 2.2.17和MySQL 5.5.8的我的开发服务器上。 只是为了笑笑,我决定对我的开发服务器进行基准testing,并遇到可能的configuration问题
如果我通过windows CLI运行ab -k -n 1000 -c 50 http://myproductionserver.com/something/restful ,我通常会在300-700个请求之间停止。 错误说:“apr_socket_recv:现有连接被远程主机强行closures(730054),完成了X个请求的总数。
我想我会检查我的Apache错误日志。 没有帮助。 这是我用ab调用的错误:
[Fri Feb 24 17:23:27 2012] [notice] Parent: child process exited with status 255 -- Restarting. [Fri Feb 24 17:23:27 2012] [notice] Apache/2.2.17 (Win32) PHP/5.3.5 configured -- resuming normal operations [Fri Feb 24 17:23:27 2012] [notice] Server built: Oct 18 2010 01:58:12 [Fri Feb 24 17:23:27 2012] [notice] Parent: Created child process 768 [Fri Feb 24 17:23:28 2012] [notice] Disabled use of AcceptEx() WinSock2 API [Fri Feb 24 17:23:28 2012] [notice] Child 768: Child process is running [Fri Feb 24 17:23:28 2012] [notice] Child 768: Acquired the start mutex. [Fri Feb 24 17:23:28 2012] [notice] Child 768: Starting 64 worker threads. [Fri Feb 24 17:23:28 2012] [notice] Child 768: Listening on port 80.
所以当我回到家时,我使用本地IP进行了相同的testing,认为这可能是一个networking问题。 同样的事情发生。 我一直在寻找相当一段时间,没有很多的答案。 我发现一个非常类似的问题,解决方法是在httpd.conf文件中使用“Win32DisableAcceptEx”,说明问题实际上是PHP .dll的一个错误。 我禁用了所有这些,但基本的MySQLi。 从上面的日志可以看出,任何事情都没有做太多。
有人有主意吗? 我认真地崩溃与1000个请求的服务器? 让我知道如果你需要更多的信息! 我知道这只是一个坐在家中的开发服务器 – 但它模仿我的生产服务器。 在继续之前,我需要把这个整理出来。 我感谢帮助!
很可能你必须查看你的apache实例的MaxClients设置和ServerLimit设置,这个设置可能比你期望的要低,以确保它不是一个Apache限制。 然而,快速浏览文档显示,两者的默认值为256,这比您的ab 50个连接限制更less。
服务器是否真的崩溃,即您需要重新启动httpd,还是一旦删除了负载,它是否继续提供请求?
我会设置logleveldebugging和httpd.conf,并尝试用更less的连接和总数n,并加快testing。 我也会看看RLimitCPU的值
RLimitNPROC
RLimitMEM
是因为它们也限制了apache可能开始杀死进程/线程/连接等。