Symptoms
Apache web server goes down periodically with the following error message in its error log:
-
on CentOS/RHEL-based distributions:
/var/log/httpd/error_log
-
on Debian/Ubuntu-based distributions:
/var/log/apache2/error.log
server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
Cause
The MaxRequestWorkers
limit has been reached and there are no free workers to serve new requests to Apache. As a result, requests are being served slowly or not served at all.
Resolution
Adjust the MaxRequestWorkers
settings for Apache. General formula looks like below:
# MaxRequestWorkers = (Total RAM - Memory used for Linux, DB, etc.) / process size
-
MPM Event: The default ServerLimit value is 16. To increase it, you must also raise
MaxRequestWorkers
using the following formula: ServerLimit value x 25 =MaxRequestWorkers
value. For example, ifServerLimit
is set to 20, thenMaxRequestWorkers
will be 20 x 25 = 500. -
MPM Prefork: The default
MaxRequestWorkers
value is 256. To increase it, you must also raiseServerLimit
.
Note: The below values are examples. They must be adjusted according to the server capabilities and load.
-
Find which Multi-Processing Module (MPM) is currently in use:
# httpd -V | grep MPM
-
Open the
/etc/httpd/conf.modules.d/01-cgi.conf
file in any text editor (For example, vi editor) and increase the values of the following directives (or add them if they are not present in the file):-
For MPM Event:
LoadModule cgid_module modules/mod_cgid.so
MaxRequestWorkers 400
ServerLimit 16 -
For MPM Prefork:
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 400
ServerLimit 400
-
-
Restart Apache to apply the changes:
# service httpd restart