Hi fellas, a hosting service I have a hand in has been having real problems with server load lately, not always because of php but a mixture of rails, php and mono is using up far too much resources and it was causing things like mail, ssh and ftp to quit or behave strangely not to mention the trouble it caused apache.
So the other night I spent all of about 5 minutes writing mod_loadavg, which as you might expect is an apache module to detect load average and act on what it finds. The module will return a pre-defined ( by you if you want ) HTTP response code when the server is too busy ( Service Unavailable makes sense and is default ).
It's configurable, but only to a degree, you can setup how load is detected ( to a degree, has to use /proc/loadavg ) and what the limits of your machine are and what HTTP response to send back, however, these variables aren't set in httpd.conf, the reason is that you'll probably never need to change the values once you have them right, to save on disk i/o and to reduce the margin for errors ( for me ) you set them when you build the module.
This module was written for apache 2, as far as I'm aware it will not work with apache 1.3 ( if you try you're on your own ).
I know it's going to be most useful to the guys here, I wrote something similar before as a php extension, but mono, rails etc are used more and more heavily, so going to the source ( apache ) makes much more sense now ...
Consult README before you do anything ...
http://spacesocket.com/loadavg-0.1.tar.gz
So the other night I spent all of about 5 minutes writing mod_loadavg, which as you might expect is an apache module to detect load average and act on what it finds. The module will return a pre-defined ( by you if you want ) HTTP response code when the server is too busy ( Service Unavailable makes sense and is default ).
It's configurable, but only to a degree, you can setup how load is detected ( to a degree, has to use /proc/loadavg ) and what the limits of your machine are and what HTTP response to send back, however, these variables aren't set in httpd.conf, the reason is that you'll probably never need to change the values once you have them right, to save on disk i/o and to reduce the margin for errors ( for me ) you set them when you build the module.
This module was written for apache 2, as far as I'm aware it will not work with apache 1.3 ( if you try you're on your own ).
I know it's going to be most useful to the guys here, I wrote something similar before as a php extension, but mono, rails etc are used more and more heavily, so going to the source ( apache ) makes much more sense now ...
Consult README before you do anything ...
http://spacesocket.com/loadavg-0.1.tar.gz