0

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.

3
  • There should be entries in error log telling you that "Max worker reached" Jul 29, 2016 at 20:28
  • @Phillip-ZyanKLee-Stockmann can you link documentation for that? I searched, but none found. Jul 29, 2016 at 20:32
  • I tried to search, too. But could not find documentation about this error. Jul 29, 2016 at 20:45

1 Answer 1

2

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

3
  • Thank you Phillip. Later I found that same log entry searching the source code. It won't fill all my requirements, but it's a start. Jul 30, 2016 at 0:00
  • If you had something more informative in mind where you could keep track of total workers, workers in use and such stuff, have a look at the mod_status httpd.apache.org/docs/2.4/mod/mod_status.html you can use tools like graphite, prometheus and even rrdtools to generate metrical graphs from that information. Jul 30, 2016 at 6:15
  • We use it with Zabbix, but as a pooling mechanism, it would not work when no workers are available. The log entry will do it for now. The only info we won't have is when workers get available again. Jul 31, 2016 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.