Apache optimization – prefork MPM

apache-2.2jmetermpm-prefork

I read many posts regarding the Apache configuration, and tried to find the best values for our servers. To make sure what's best I used JMeter to simulate 2100 connections per second. After many rounds of fine tuning i got to the following configuration:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   10
ServerLimit     2048
MaxClients       2048
MaxRequestsPerChild  20000
</IfModule>

Server details:

[root@web06 ~]# free
                 total       used       free     shared    buffers     cached
    Mem:       3814660    1070152    2744508          0     146788     766944
    -/+ buffers/cache:     156420    3658240
    Swap:      5210104          0    5210104
[root@web06 ~]# grep -c processor /proc/cpuinfo
4
[root@web06 ~]# uname --a
Linux web06 2.6.18-164.el5PAE #1 SMP Thu Sep 3 04:10:44 EDT 2009 i686 i686 i386 GNU/Linux

Memory used by a single Apache process:

[root@web06 ~]#  cat /proc/5903/status  | grep VmRSS 
VmRSS:     10076 kB

I know that my configuration is a bit high, but configuration gave me the best result on the stress test. I would appreciate your input, should I change anything?

Please note- I know there are better alternative to Apache, but I don't have the resources to make this kind of a change at the moment.

Thanks!

Best Answer

Well, is your server capable of running 2048 concurrent Apache processes (as you set in ServerLimit/MaxClients)? I bet it is not and actually you don't need so many concurrent Apache workers. I highly recommend you to setup an asynchronous reverse proxy like nginx or lighttpd to offload handling clients w/slow connections to that async proxy. And believe me most of the public web clients are slow enough to take most of Apache worker time just to handle uploading of already generated content to them. And I don't think you will ever need more than 25 concurrent Apache workers if you set up reverse proxying properly.