Apache prefork optimization - Choosing the right `MaxRequestsPerChild` value

Solution 1:

MaxRequestsPerChild is really only useful to limit the amount of memory leakage over time when running dynamic scripts. If you are just serving static content or very small/simple scripts then you can probably set it to 0 or very high without much effect. If you are running larger/complex scripts then setting it 0/high will result in your Apache processes consuming more and more memory. Exactly how much more depends on your specific application.

On the other side, setting it very low may actually result in slightly more CPU usage as the Apache processes are constantly being restarted.

I would do a simple test to see how much memory your processes can use. Set MaxRequestsPerChild to 0 and restart Apache. Test load a few pages and see what the initial size of the Apache processes are using top. Check again after a few hours/days/weeks (depending on your application and page views) and see how it grows. If it doesn't grow very much then a 0 or very large value for MaxRequestsPerChild should be fine.

If you have a set maximum size for your Apache processes (i.e., you want them to be 50MB or less) then you can do the same test with various values of MaxRequestsPerChild until you find a value that keeps Apache less than that.