0

I've been deployed on AWS Elastic Beanstalk a Django application. Lately I'm having problems with Apache since it restarts often.

See my Elastic Beanstalk dashboard

Initially looking at the file /var/log/httpd/error_log I was getting the following error:

[Wed Apr 12 08:50:51.371533 2017] [mpm_prefork:error] [pid 17847] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

So I configured Apache as follow:

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 500

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
KeepAliveTimeout 20

<IfModule mpm_prefork_module>
    ServerLimit 60
    MaxRequestWorkers 1000
    StartServers 18
    MinSpareServers 3
    MaxSpareServers 6
    MaxConnectionsPerChild 1000
    ListenBacklog 1000
</IfModule>

The problem has not been solved and the following are the errors:

[Tue Apr 18 00:15:23.037564 2017] [mpm_prefork:error] [pid 7816] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
...
[Tue Apr 18 03:01:01.786908 2017] [mpm_prefork:notice] [pid 7816] AH00173: SIGHUP received.  Attempting to restart
[Tue Apr 18 03:01:01.851941 2017] [so:warn] [pid 7816] AH01574: module wsgi_module is already loaded, skipping
[Tue Apr 18 03:01:01.874858 2017] [mpm_prefork:warn] [pid 7816] AH00181: MaxRequestWorkers of 1000 exceeds ServerLimit value of 60, decreasing to match
[Tue Apr 18 03:01:01.875556 2017] [auth_digest:notice] [pid 7816] AH01757: generating secret for digest authentication ...
[Tue Apr 18 03:01:01.876190 2017] [lbmethod_heartbeat:notice] [pid 7816] AH02282: No slotmem from mod_heartmonitor
[Tue Apr 18 03:01:01.927425 2017] [mpm_prefork:notice] [pid 7816] AH00163: Apache/2.4.25 (Amazon) mod_wsgi/3.5 Python/3.4.3 configured -- resuming normal operations
[Tue Apr 18 03:01:01.927452 2017] [core:notice] [pid 7816] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Update:

ServerLimit must be greater than or equal to MaxRequestWorkers.

<IfModule mpm_prefork_module>
    ServerLimit 1000
    MaxRequestWorkers 1000
    StartServers 18
    MinSpareServers 3
    MaxSpareServers 6
    MaxConnectionsPerChild 1000
    ListenBacklog 1000
</IfModule>

Now, I'm no longer getting mpm_prefork errors/warnings and Apache doesn't shut down anymore.

Fabio
  • 121
  • 5
  • You overwrite the MaxRequestWorkers setting but you should overwrite the ServerLimit setting aswell (at the same value) which is the top level limit of your apache server (as this line said : MaxRequestWorkers of 1000 exceeds ServerLimit value of 60, decreasing to match). Can you post the syslog/message log (/var/log/...), you should have some logs concerning the sighup signal sent to apache. – Jérémy Munoz Apr 20 '17 at 10:01
  • @JérémyMunoz Thanks, you're right. Now `ServerLimit` has been set to 1000 as `MaxRequestWorkers`. I'll see If the problem persists. – Fabio Apr 20 '17 at 10:48

0 Answers0