Performance Issue due to server reached MaxRequestWorkers on Apache httpd
Environment
-
Red Hat Enterprise Linux (RHEL) 7.x
- Apache httpd-2.4.6
-
Red Hat Enterprise Linux (RHEL) 8.x
- Apache httpd-2.4.37
-
Red Hat Enterprise Linux (RHEL) 9.x
- Apache httpd-2.4.x
-
JBoss Web Server (JWS) 3.x
- Apache httpd 2.4.x -
Jboss Core Services httpd 2.4.x
Issue
-
The Apache httpd hangs after reaching 256 connections. We see below error message in error_log.
AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting -
The Apache httpd server is running out of MaxRequestWorkers very quickly. How to increase MaxRequestWorkers?
-
Httpd only allowing 256 connections in
Prefork mpm
Resolution
- Increase the
MaxRequestWorkersto the desired value and also specify theServerLimitto the same value asMaxRequestWorkers(assuming prefork in use). Please note thatMaxRequestWorkersis optimal at 200 * (total # of cpu cores on the server/host) for the prefork mpm and around 300 * (total # of cpu cores on the server/host) for the worker/event mpm.
For example If there are 4 cpu core and using prefork mpm, it gives 4 * 200 = 800 processing power, to handle 800 concurrent user load capability. It can use the example configuration as follows in Apache httpd httpd.conf OR /etc/httpd/conf.modules.d/00-mpm.conf file.
<IfModule mpm_prefork_module>
ServerLimit 800
StartServers 5
MinSpareServers 75
MaxSpareServers 800
MaxRequestWorkers 800
MaxRequestsPerChild 0
</IfModule>
-
For a reference, see Content from httpd.apache.org is not included.Content from httpd.apache.org is not included.https://httpd.apache.org/docs/2.4/mod/prefork.html
-
If you face this after upgrading to JBCS httpd 2.4.51+, see httpd exhausted with smaller pool size after upgrading to JBCS httpd 2.4.51
-
If you have not already optimized configuration then refer to This content is not included.Load Balancer Configuration Tool and optimize the configuration in Apache httpd which typically resolves most problems seen with worker/prefork/event MPM.
-
For understanding the MaxClients / MaxRequestWorkers Apache httpd is capable to handle as per your server resource limitation, please refer to https://access.redhat.com/solutions/770923
Root Cause
- Server has used up the request worker limit specified in directive
MaxRequestWorkers - For prefork mpm
ServerLimitdefaults to 256, so if theMaxRequestWorkersis increased beyond that number, Apache httpd will throw a warning message and truncate theMaxRequestWorkersdown to 250.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.