Search code examples
phpapachelong-integerpolling

php way to determine if apache has connections waiting


Ok, I have a feature that I would like to implement some type of long polling. The only problem is, I don't want to bump up against the "maxconnections" problem. I figure I could have my PHP process wait for updated data only if Apache has no waiting connections. If there are waiting connections, I would simply return immediately and the client would return to a short polling interval.

So, to clarify, the question is: how do I get the number of waiting connections for Apache in PHP?


Solution

  • Once you have waiting connections it's probably too late to programatically deal with it. You can get information about active connections by executing netstat.

    Try something like exec('netstat | grep http | wc -l'); and then process the result.

    It's not exactly what you are looking for because it will include all apache requests including images, css and javascript but will give you information about the number of active connections