Performance Issue due to server reached MaxRequestWorkers on Apache httpd

Solution Verified - Updated

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 MaxRequestWorkers to the desired value and also specify the ServerLimit to the same value as MaxRequestWorkers (assuming prefork in use). Please note that MaxRequestWorkers is 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>

Root Cause

  • Server has used up the request worker limit specified in directive MaxRequestWorkers
  • For prefork mpm ServerLimit defaults to 256, so if the MaxRequestWorkers is increased beyond that number, Apache httpd will throw a warning message and truncate the MaxRequestWorkers down to 250.
Components
Category
Tags

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.