Applicable to:
- Plesk 12.5 for Linux
- Plesk Onyx 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
- On CentOS/RHEL-based distributions:
-
The server is not under DDoS attack:
-
This command shows the list of source IP addresses and number of their current connections:
# netstat -an | egrep ':80|:443' | grep ESTABLISHED | awk '{print $5}' | grep -o -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sort -n | uniq -c | sort -nr
499 203.0.113.2
318 203.0.113.5
213 203.0.113.8If the number of connections is high (400+) for some IP addresses, follow the steps from this KB article.
-
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:
Note: The below values are just an example. They should be adjusted according to the server capabilities and load. The default MaxRequestWorkers
value is 256. To increase it, you must also raise ServerLimit
.
Be careful, too high values of MaxRequestWorkers
and ServerLimit
directives may cause Apache to become unresponsive.
-
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:
CONFIG_TEXT: <IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
MaxRequestWorkers 400
ServerLimit 400
</IfModule> -
For MPM Prefork:
CONFIG_TEXT: <IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 400
ServerLimit 400
</IfModule>
-
-
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 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):CONFIG_TEXT: MaxRequestWorkers 400
ServerLimit 400 -
For MPM Prefork:
Open the
/etc/apache2/mods-enabled/mpm_prefork.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):CONFIG_TEXT: MaxRequestWorkers 400
ServerLimit 400
-
-
Restart Apache to apply the changes:
# service apache2 restart
Additional Information
Identifying a possible cause
We recommend to identify the cause of the MaxRequestWorkers
limit being reached. Click on the "See how" section for details:
-
Find websites that slow down Apache:
The other reason why the number of worker processes can increase is how long it takes to process a request.
-
Enable Apache server statistics according to this KB article and monitor Apache web-server performance.
Check the SS, Req fields and check what websites and pages have higher values. If it requires a significant time to process a .php script, the code of this script should be reviewed and optimized.
-
A significant time to process MySQL queries can also be the reason. Check this KB article to track down slow SQL queries.
-
-
Switch websites with high traffic load to nginx-only hosting:
If there are websites with high traffic load, switching websites to nginx-only hosting allows decreasing the load on Apache. To do this:
2.1. Install and enable the nginx web-server.
2.2. Once installed, switch on nginx-only hosting for a domain.
- Apache HTTP Server Version 2.4: Apache Performance Tuning
- Apache MPM Common Directives: MaxRequestWorkers Directive
Comments
5 comments
I am tired of plesk, i inscreased this and it is still happening
Still having the same issue on two servers despite raising
MaxRequestWorkers
to 1000@Dan, Am I right that even after changing 'MaxRequestWorkers' to 1000 and restarting apache you still see 'server reached MaxRequestWorkers setting' errors in apache logs? Additionally, you may check this article which contains troubleshooting steps.
for mpm_event where i can change MaxRequestWorkers value?
@Luis, the path is almost the same:
Debian/Ubuntu /etc/apache2/mods-enabled/mpm_event.conf
CentOS the same file but <IfModule mpm_event_module> section.
Please sign in to leave a comment.