UPDATE: thanks to all the answer given, but they are all about the system load, and not the apache.
My goal is to understand, inside my php scripts (the templating ones), when apache have an high load and is prefearrable to fork some traffic on lighttpd, that is here just to the long-polling and to light the apache's load.
Hi guys, after this question i've started to use lighttpd for a long-polling service on my server, in order to not to nuke apache and the database forn this kind of requests.
Then, i started to use lighttpd also to static content (images, css, js, and so on).
So, actually, i have example.com served by apache, and polling.example.com served by lighttpd, both using memcache to reduce the database hits.
In apache, i've set the proxy module to proxy out all the requests to example.com/polling/* at polling.example.com/*
Now, im wondering if there is a way to retrieve the apache server load in php, in order to redirect even other ajax requests on lighttpd if apache have an high load.
I mean, something like:
<?php
$apache_server_load = /*hot to retrieve this value?*/;
if($apache_server_load >= $my_defined_max_load){
$ajax_domain = '/polling';
}else{
$ajax_domain = '';
}
?>
<script>
[...]
$.ajax({
url: '<?php echo $ajax_domain; ?>/mypage.php',
[...]
});
[...]
</script>
edit im running on Debian
p.s: i'll also like to hear if this solution can be a nice approach, but would be another question.. feel free to comment if you like.