1

I have allocated 5GB of memory for Apache processes.

While basing on the fact that each Apache process consume in average 42.5MB I've set the following on my server (while calculating as if each process consumes 50MB of memory):

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          100
    MaxRequestsPerChild   0
</IfModule>

Now for the questions:

  1. How can I determine how much StartServers to set?
  2. While not being able to set Worker mpm (PHP etc.), does load balancing is my best option for high traffic?
  3. How can I reduce Apache process memory? my website use CDN to serve assets to the user while the server eventually serve HTML only.

I've read answers here and searched a lot in Google for that questions and couldn't find anything specific enough.

1

Beware: most apache process shares most of its memory with its parents/siblings. You can't easily sum the values of the from apache processes allocated memory. The best what you can do: you start a lot of apache processes and check how this change your allocated memory.

1: StartServers has only a limited importance. It means, how many child process will be started initially. Min/MaxSpareServers are much more important.

2: I can't understand, you didn't said anything your load balancing solution. If you want to be able to handle high traffic, your best option were to use a worker apache (or even an other type of http server) for static file serving, and a prefork-based (I suggest you mpm-itk) for dynamic languages (probably for php). The worker should forward the dynamic requests to the prefork-based server. This structure is also capable to be easily extended to a load-balanced cluster solution.

3: MayRequestPerChild==0 means, that the processes won't ever restarted. Thus if there is a problem with them, it weren't ever fixed, or if they are leaking, this also won't be solved. It can be ok if your system is rock-stable, and you are using only perfect garbage collected languages on the server side (php isn't one of them!), but I think, from practical reasons it is better to use a big integer value (in most cases I use 100 or 500). Beware: a simple child process restart isn't really costly compared to its handling of 100-500 requests.

  • Thank you for your response. 1. How can I determine the number of Min/MaxSpareServers then? 2. Since I'm not able to change the server type at the moment and by that kind of urged to use Prefork, Does load balancing option is pretty much what I can do to handle high traffic? 3. So by setting MaxRequestPerChild the apache process memory consumption will be reduced also? or it's just a best practice I should follow to avoid "hanging" processes? – Shahar Galukman Jul 24 '14 at 12:24
  • 1: A big difference between Min/MaxSpareServers means more unused (currently not working) apache child processes, but also it means there is always more processes ready to work on the spot. A big MinSpareServers means the same, and also a big MaxSpareServers. 2: I don't have any idea what are you understanding on "load balancing", but probably it isn't in the common sense. 3: In most cases, a larger MaxRequestsPerChild means bigger memory usage and smaller cpu usage, but the correlation is weak and non-trivial. – peterh Jul 24 '14 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.