Welcome to WebmasterWorld Guest from 54.167.85.221

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Script increase server load, what to do?

...seeing stuck httpd requests using top command

     

Imaster

10:53 am on Sep 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

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.

Thanks!

vincevincevince

11:27 am on Sep 21, 2007 (gmt 0)

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member



How long do your scripts take to execute? It sounds to me like something's not finishing.

Imaster

11:47 am on Sep 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

vincevincevince

11:51 am on Sep 21, 2007 (gmt 0)

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month