homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP Script increase server load, what to do?
...seeing stuck httpd requests using top command

 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.




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

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


 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.


 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:

As the last two lines:
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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved