It is essential to tune Apache's MaxRequestWorkers setting to mitigate the risk of resource usage problems that could lead to a crash and to ensure that your server can use the resources available to it.
If you see the following in the Apache error log, it is an indicator that you will need to adjust the MaxRequestWorkers setting:
AH00286: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
You can search for this message with the following command:
grep MaxRequestWorkers /etc/apache2/logs/error_log
There are three critical things to keep in mind when evaluating this issue and adjusting the configuration:
- The purpose of MaxRequestWorkers is to limit Apache from using all of the resources on the server.
- Setting the MaxRequestWorkers configuration too low will allow resources that you are paying for to go unused. Ideally, the setting would be set high enough that the server is using a large portion of the available resources but still has enough free resources to maintain stability.
- Setting the MaxRequestWorkers configuration too high will allow Apache to use too many resources during periods of high traffic. Setting the limit too high could allow the server to crash.
cPanel support is not able to provide you with a specific configuration because the required configuration will change base on several variables, including but not limited to the following:
- The resources available on your server
- The kind of websites on the server
- The specific patterns of traffic that the server must handle
- Any other software that is added to or removed from the server
Due to this, every server that receives any amount of moderate traffic must tune Apache to match the requirements of your specific situation. You must then monitor the server and adjust the tuning if anything changes.
Although cPanel support is not able to tune the server for you, we can provide some guidelines for how to go about doing this.
Usually, the concern is that the server will run low on memory. You can determine if your MaxRequestWorkers configuration will limit Apache's memory usage with the following steps:
- Determine how much memory, on average, your Apache processes use. You can get this by reviewing the RSS column from the following command and divide it by 1024 to convert it to MB:
ps -ylC httpd --sort:rss
- Take the total amount of memory available to the server and subtract the amount of memory that is required for non-Apache processes. The remaining memory is what you will reserve for Apache.
- Take the remaining amount of ram and divide that by the average amount of memory that you expect each Apache process to use.
- The resulting number will be your MaxRequestWorkers value.
NOTE: The MaxRequestWorkers value is limited by the ServerLimit value. You may need to increase the ServerLimit value in order to increase the MaxRequestWorkers value.
You can update the MaxRequestWorkers value in WHM with the following steps:
- Log in to WHM as the root user.
- Navigate to Home »Service Configuration »Apache Configuration »Global Configuration.
- Update the "Max Request Worker" value.
- Set the ServerLimit value to something larger than MaxRequestWorkers
- Select Save.
The above process is what the Apache documentation recommends, as outlined here:
Apache's Documentation: Hardware and Operating System Issues