2

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

aneuryzm
  • 1,614
  • 5
  • 25
  • 40

2 Answers2

1

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.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • I can second that. Have a look at how much memory each instance of apache eats up. Then see how many processes you can afford to have running at the same time (with each using that much memory). So, a rhough starting point might be (total memory) / (2 for system stability and other processes) / (memory per process) as MaxClients. From then on, watch (top) your mem usage and adjust as seen fit. – Andreas Reiff Oct 06 '12 at 14:55
0

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.

al.
  • 915
  • 6
  • 17