Improving mod_perl Driven Site's Performance -- Part VII: Performance Tuning by Tweaking Apache Configuration Page 2
Let's raise the request load to 100 x 10 (10 users, each makes 100 requests):
% ./ab -n 1000 -c 10 http://www.example.com/perl/access/access.cgi Concurrency Level: 10 Complete requests: 1000 Failed requests: 0 Requests per second: 139.76
As expected, nothing changes -- we have the same 10 concurrent users. Now let's raise the number of concurrent users to 50:
% ./ab -n 1000 -c 50 http://www.example.com/perl/access/access.cgi Complete requests: 1000 Failed requests: 0 Requests per second: 133.01
We see that the server is capable of serving 50 concurrent users at
133 requests per second! Let's find the upper limit. Using -n
10000 -c 1000 failed to get results (Broken Pipe?). Using -n 10000
-c 500 resulted in 94.82 requests per second. The server's
performance went down with the high load.
The above tests were performed with the following configuration:
MinSpareServers 8 MaxSpareServers 6 StartServers 10 MaxClients 50 MaxRequestsPerChild 1500
Now let's kill each child after it serves a single request. We will use the following configuration:
MinSpareServers 8 MaxSpareServers 6 StartServers 10 MaxClients 100 MaxRequestsPerChild 1Simulate 50 users each generating a total of 20 requests:
% ./ab -n 1000 -c 50 http://www.example.com/perl/access/access.cgiThe benchmark timed out with the above configuration.... I watched the output of
psas I ran it, the parent process just wasn't capable of respawning the killed children at that rate. When I raised theMaxRequestsPerChildto 10, I got 8.34 requests per second. Very bad - 18 times slower! You can't benchmark the importance of theMinSpareServers,MaxSpareServersandStartServerswith this kind of test.Now let's reset
MaxRequestsPerChildto 1500, but reduceMaxClientsto 10 and run the same test:MinSpareServers 8 MaxSpareServers 6 StartServers 10 MaxClients 10 MaxRequestsPerChild 1500I got 27.12 requests per second, which is better but still 4-5 times slower. (I got 133 with
MaxClientsset to 50.)Summary: I have tested a few combinations of the server configuration variables (
MinSpareServers,MaxSpareServers,StartServers,MaxClientsandMaxRequestsPerChild). The results I got are as follows:
MinSpareServers,MaxSpareServersandStartServersare only important for user response times. Sometimes users will have to wait a bit.The important parameters are
MaxClientsandMaxRequestsPerChild.MaxClientsshould be not too big, so it will not abuse your machine's memory resources, and not too small, for if it is your users will be forced to wait for the children to become free to serve them.MaxRequestsPerChildshould be as large as possible, to get the full benefit of mod_perl, but watch your server at the beginning to make sure your scripts are not leaking memory, thereby causing your server (and your service) to die very fast.Also it is important to understand that we didn't test the response times in the tests above, but the ability of the server to respond under a heavy load of requests. If the test script was heavier, the numbers would be different but the conclusions very similar.
The benchmarks were run with:
