I have a question about Apache MPM Prefork configuration on VPS servers.
One slicehost articles, they suggest to set MaxClients to 40 if I have 256MB RAM on my virtual server. (http://articles.slicehost.com/2010/5/20/configuring-the-apache-mpm-on-debian)
However since each client request uses approx 50MB RAM memory, swapping is guaranteed and my VPS slows down.
PID RSS COMMAND
10146 45944 /usr/sbin/apache2 -k start
10147 52528 /usr/sbin/apache2 -k start
10150 49680 /usr/sbin/apache2 -k start
10151 48756 /usr/sbin/apache2 -k start
I've found out that if I set MaxClients to 4 (!) instead, I don't get any swapping, and the webserver is supposed to be faster (or am I wrong?)
So, I don't understand why they do suggest 40 instead.
thanks
The amount of MaxClients you can have purely depends on the nature of your site.
If you are serving out mostly static content, then Apache doesn't use very much memory and 40 (or more) can be set to MaxClients.
On the other hand, if you do have some memory-heavy stuff going on (such as you run a CMS like Drupal or a blog with WordPress), memory requirements per process will heavily balloon and so goes down the MaxClients value you can have. With those heavy PHP applications a single process can easily consume anything from 10 to ??? megabytes of RAM.
They probably suggest that, because 50 MB memory per request is not the common thing.
You should probably check, if you can get rid of any modules you're using. Also check if you can move any mod_ (like mod_php) to fcgid.
After you did that, you probably have only thread-safe modules left and can safely switch to worker MPM, which will likely resolve all your performance problems.