Applicable to:
- Plesk for Linux
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
CONFIG_TEXT: 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.) / average Apache 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 a 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:
CONFIG_TEXT: <IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
MaxRequestWorkers 400
ServerLimit 16
</IfModule> -
For MPM Prefork:
CONFIG_TEXT: <IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 400
ServerLimit 400
</IfModule>
-
-
Save the changes and close the file.
-
Restart Apache to apply the changes:
# service httpd restart
-
Find which Multi-Processing Module (MPM) is currently in use:
# apache2ctl -V | grep MPM
-
Change the MPM configuration:
-
For MPM Event:
Open the
/etc/apache2/mods-enabled/mpm_event.conf
in a 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):CONFIG_TEXT: MaxRequestWorkers 400
ServerLimit 16 -
For MPM Prefork:
Open the
/etc/apache2/mods-enabled/mpm_prefork.conf
file in a 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):CONFIG_TEXT: MaxRequestWorkers 400
ServerLimit 400
-
-
Save the changes and close the file.
-
Restart Apache to apply the changes:
# service apache2 restart
Note: if the issue persists, switch MPM to Prefork in Tools & Settings > Apache Web Server.
Comments
1 comment
Hi Kuzma Ivanov,
Please note that the results of calculations for lots and lots of servers, of the below, to the best of my understanding totally does not suit, the default recommended values, as set in this current article.
Can you please advise?
MaxRequestWorkers = (Total RAM - Memory used for Linux, DB, etc.) / average Apache 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
.MPM EVENT
Please sign in to leave a comment.