Apache web server goes down: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

Created:

2017-06-14 04:24:25 UTC

Modified:

2017-08-17 09:06:25 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Apache web server goes down: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

Applicable to:

  • Plesk for Linux

Symptoms

Apache web server goes down periodically with the following error in error log ( /var/log/httpd/error_log for RedHat based distributions, /var/log/apache2/error.log for Debian based distributions):

 [mpm_event:error] [pid 44099:tid 140542724503680] AH00484: 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 the web server. As a result requests are being served slowly or not server at all.

Resolution

The most important is to define the reason why the number of request processes is out of limits.

  1. Check if the the server is under DDoS attack:

    • make sure that there are a lot of connections and specific IP addresses. This command show the source IP addresses and numbers of the 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
      
      299 203.0.113.2
      118 203.0.113.5
      8 199.1.103.2

      and find the domains under attack via the command:

      # grep `203.0.113.2` /var/www/vhosts/system/*/logs/access_log
      
    • Check how to avoid DDoS attack - KB #213390069

    • Edjust Fail2ban/Firewall settings and configuration. Disable affected domain for some time.

  2. The other reason why number of worker processes can increase is how long it takes to process requests. Monitor Apache webserver performance using mod_status module. Enable mod_status using steps below:

    • create 11-mod_status.conf file with the following content:

      # touch /etc/httpd/conf.modules.d/11-mod_status.conf
      
      # cat /etc/httpd/conf.modules.d/11-mod_status.conf
      <Location "/server-status">
      SetHandler server-status
      Order allow,deny
      Allow from all
      </Location>
      # service httpd reload
    • access server statistics by using a Web browser with the URL http://your.server.name/server-status

    Check SS , Req fields and check what websites and pages have a higher values. If it requires a significant time to process .php script, code of this script should be reviewed.

    A significant time to process MySQL queries also could be a reason. Check the following article to find how to troubleshoot:

    Server is slow due to high CPU usage by mysql process

    How to troubleshoot High CPU usage by MySQL?

  3. If there are any websites with high traffic load, switching to server the website only by Nginx web server allows to decrease load on Apache. Disable Proxy mode option in Websites & Domains > Apache & nginx Settings

  4. If there are no attack on the server and number of request processes is growing by legit reasons, adjust MaxRequestWorkers and ServerLimit parameters:

    For Debian-based OS:

    # cat /etc/apache2/mods-enabled/mpm_event.conf
    
    ...
    MaxRequestWorkers 300
    ServerLimit 300
    ...

    For RHEL-based OS:

    # cat /etc/httpd/conf.modules.d/00-mpm.conf
    
    ...
    <IfModule mpm_event_module>
    LoadModule cgid_module modules/mod_cgid.so
    MaxRequestWorkers 400
    ServerLimit 400
    </IfModule>
    ...

    Note that too high values can affect server performance and cause Apache web server crash if there is not enough RAM to serve all requests.

    Calculate the max applicable value as follows - determine the size of your average Apache process, by looking at your process list via a tool such as top, and divide this into your total available memory, leaving some room for other processes. MaxRequestWorkers and ServerLimit should not be higher than such value.

    Once max available value is calculated, start to increase it MaxRequestWorkers and ServerLimit iteratively and monitor the server.

Have more questions? Submit a request
Please sign in to leave a comment.