I'm building monitoring system that will detect how many (idle) requests are currently being processed. The method that I'm using to detect this is by connecting to http://localhost/server-status .

The question is, if Apache can't serve any more new connection (ex: MaxClients reached the top) how am I able to detect apache statistic then? Is it possible that Apache is smart enough to ignore MaxClients configuration for connections from localhost?

Any help is appreciated.

| improve this question | | | | |

I believe the answer is no, with two reasons (and a third, wooly one):

  1. Suppose requests to /server-status/ were immune to MaxClients (but incremented the client count). Then, it would become too easy to DoS apache with requests so legitimate ones cannot be served (and since they can go way over MaxClients, there is no chance real ones will ever get responded to)

  2. Apache will likely have it's client count based on [some function of] the number of open connections (one connection to :80 can only send one request at a time, but KeepAlive allows us to reuse it, so open one TCP connection is essentially one client). This will be checked before the headers are even read (if there is space, it will delegate the request to be dealt with. If there aren't, it'll fail fast).

  3. Whenever I'm overloaded with connections, service httpd fullstatus works really slowly or not at all :-)

| improve this answer | | | | |
  • about 3) It's interesting that in debian I can't use /etc/init.d/apache2 status. I have to use #apache2ctl status which is just bash scripts that connects to localhost/server-status. – confiq Nov 4 '12 at 14:59
  • 1
    Yeah, the latter used to work (/etc/init.d/apache2 status) but I don't know why they changed it. IIRC all implementation of that just did lynx -dump http://localhost/server-status anyway. – Jay Nov 4 '12 at 15:01
  • Confirmed through direct testing of apache 2.2.22 on Ubuntu Precise (in a VM) with mpm_prefork: mod_status is not exempt from MaxClients. If Apache is out of available children, requests to /server-status will hang just like any other request. I realize this is a pretty old question, but it's the only google result for exactly this question when I searched, and there was no definitive answer. – Lexelby Jun 7 '18 at 15:05

You might need to write an apache module (or modify mod_status) so that other interface is used for the communication with apache server. You might want to use posix signals and shared memory or a file to request and get the stats.

| improve this answer | | | | |
  • 1
    Sorry, but there's simply no other way to do it. – FINESEC Nov 4 '12 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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