httpd log when no workers are available

Is there a way to httpd log somehow when there are no more workers available?

For example, it could log the date and time workers became unavailable and log again when there are workers available again.

This log would be used to analize capacity needs.

Replay

As we both could not find any documentation about the server reached MaxRequestWorkers setting log entry and I knew for sure they were there (hit them in the past), I tried it myself. These are the steps I took to replicate the message:

mpm prefork

# lxc launch ubuntu:16.04 test
# lxc exec test /bin/bash
# apt-get update ; apt-get -y install apache2
# a2enmod mpm_prefork
# cat >/etc/apache2/mods-available/mpm_prefork.conf <<EOF
<IfModule mpm_prefork_module>
        StartServers              1
        MinSpareServers           1
        MaxSpareServers           3
        MaxRequestWorkers         5
        MaxConnectionsPerChild    0
</IfModule>
EOF
# service apache2 restart
# apt-get install wrk
# wrk -d 60 -c 10 -t 10 http://localhost

Now have a look at /var/log/apache2/error.log - you should see a line similar to this:

[Fri Jul 29 20:59:18.304444 2016] [mpm_prefork:error] [pid 5419] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

I guess the exact wording of the error message depends on the used mpm and on what limit the server reached first.

mpm event

So I tried the event mpm as well:

# a2dismod mpm_prefork
# a2enmod mpm_event
# cat >/etc/apache2/mods-available/mpm_event.conf <<EOF
<IfModule mpm_event_module>
        StartServers                     1
        MinSpareThreads          1
        MaxSpareThreads          2
        ThreadLimit             2
        ThreadsPerChild          2
        MaxRequestWorkers         5
        MaxConnectionsPerChild   0
</IfModule>
EOF
# service apache2 restart
# wrk -d 10 -c 50 -t 50 http://localhost

And voilá:

[Fri Jul 29 21:06:57.148442 2016] [mpm_event:error] [pid 5643:tid 139946523182976] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

mpm worker

# a2dismod mpm_event
# a2enmod mpm_worker
# cat >/etc/apache2/mods-available/mpm_event.conf <<EOF
<IfModule mpm_worker_module>
        StartServers                     1
        MinSpareThreads          1
        MaxSpareThreads          2
        ThreadLimit              2
        ThreadsPerChild          2
        MaxRequestWorkers        5
        MaxConnectionsPerChild   0
</IfModule>
EOF
# service apache2 restart
# wrk -d 10 -c 50 -t 50 http://localhost
# tail -1 /var/log/apache2/error.log
[Fri Jul 29 21:11:20.033223 2016] [mpm_worker:error] [pid 5805:tid 140034844882816] AH00287: server is within MinSpareThreads of MaxRequestWorkers, consider raising the MaxRequestWorkers setting

conclusion

we found no documentation, but we can be sure it is there: you will get noticed by httpd2.4 if you reach the MaxRequestWorkers setting.
You need to watch the error.log closely, though, as this message is not repeated every time you hit the limit. Not sure if it is repeated after a defined timespan, but you will for sure be notified after a restart of httpd2.4

Category: apache 2.4 Time: 2016-07-29 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.170 (s). 12 q(s)