I wrote a RESTful web service to be the backbone behind a mobile app using PHP and the Restler library. It's running on my dev server running Windows Server 2008 R2, PHP 5.3.5, Apache 2.2.17, and MySQL 5.5.8. Just for giggles I decided to benchmark my dev server and ran into a possible configuration issue
If I run ab -k -n 1000 -c 50 http://myproductionserver.com/something/restful
through the windows CLI I usually get stopped between 300-700 requests. The error says "apr_socket_recv: An existing connection was forcibly closed by the remote host. (730054). Total of X requests completed."
I figured I would check my Apache Error logs. Not Helpful. Here's the error I invoked with 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.
So when I got home, I ran the same test using my local ip- thinking it might be a network issue. Same thing happened. I've been searching for quite a while with not a lot of answers. I found a very similar problem and the resolution was to use "Win32DisableAcceptEx" in the httpd.conf file saying the issue is actually a bug with PHP .dlls. I disabled all of them but the basic MySQLi. As you can tell from the logs above, neither did much of anything.
Anyone have any ideas? Am I seriously crashing the server with 1000 requests? Let me know if you need more info! I know it's just a dev server sitting at home- but it mimics my production server. I'll need to have this sorted out before moving forward. I appreciate the assistance!
Its likely that you would have to look at the MaxClients setting and the ServerLimit settings for your apache instance, which might be lower than you might expect to be sure its not an apache limit being imposed. However a quick look at the docs suggest that the default for both is 256, which is less that your ab imposed 50 connections limit.
Is the server actually crashing, ie you need to restart httpd or does it continue to serve requests once the load has been removed?
I would set loglevel debug and httpd.conf, and try with fewer connections and total n, and ramp up the test. I would also look and see what the values for RLimitCPU
RLimitNPROC
RLimitMEM
are as they are also limits at which apache might start killing processes/threads/connections etc.