Msg#: 3456859 posted 10:53 am on Sep 21, 2007 (gmt 0)
I have built a php script and am using it on my apache server (php version 4 and red hat linux).
The problem that I am facing is that whenever I use the "top" command via ssh on my server, it shows a stuck httpd request due to these php scripts. The request remains stuck for an unforeseen time, increases memory usage and thus increases server load and processing power. Not just 1, there are several such httpd requests running for a very long time and I could say that they terminate only when I do a apache restart.
I have even tried using mysql_free_results, but even that does not seem to work. Any tips on how do I go about debugging this problem.
Msg#: 3456859 posted 11:47 am on Sep 21, 2007 (gmt 0)
the scripts load within seconds. There does not seem to be a problem with the script loading. In fact if there are 100 different requests to this scripts, they all load fast and not all of them get stuck in the memory. Out of these, I can say that around 1% of the scripts may be getting stuck.
Msg#: 3456859 posted 11:51 am on Sep 21, 2007 (gmt 0)
First thing I'd do is to upgrade PHP to 5.1 at the minimum. Then, check that your apache is pretty recent.
Next, try to start debugging actual script execution times.
At the top: $time=time();
As the last two lines: $duration=time()-$time; if ($duration>5) error_log("Long running script - took $duration sections");
You should then be able to view your error_log and see exactly how long the slow scripts are taking. From there, try to work backwards ... error_log $_GET arguments, user IDs, etc. until you find out what is special about these particular executions.