PHP performance issue

This is a discussion on PHP performance issue within the PHP General forums, part of the PHP Programming Forums category; CentOS 4.2, Apache 2.0, PHP 4.3.9, PHP loaded as a module I've got a fairly ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-07-2006
DaveInPNG
 
Posts: n/a
Default PHP performance issue

CentOS 4.2, Apache 2.0, PHP 4.3.9, PHP loaded as a module

I've got a fairly complicated page using MySQL that from the user's
perspective, takes about 2 seconds to load. According to TOP, the CPU
goes to 100% during this time.

If I use microtime() at the top and the bottom of the code, it says the
code takes 0.3 seconds.

So how can I find out where the slow load times are coming from? I'm
running my tests from another computer on the same switch.

Thanks.

Reply With Quote
  #2 (permalink)  
Old 05-07-2006
hug
 
Posts: n/a
Default Re: PHP performance issue

"DaveInPNG" <CTS-Subscriptions1@sil.org.pg> wrote:

>CentOS 4.2, Apache 2.0, PHP 4.3.9, PHP loaded as a module
>
>I've got a fairly complicated page using MySQL that from the user's
>perspective, takes about 2 seconds to load. According to TOP, the CPU
>goes to 100% during this time.
>
>If I use microtime() at the top and the bottom of the code, it says the
>code takes 0.3 seconds.
>
>So how can I find out where the slow load times are coming from? I'm
>running my tests from another computer on the same switch.
>
>Thanks.


First thing is to make sure about the placement of microtime(), if it
says there's 0.3 seconds between calls then that's what there is.

Next thing is to start wrapping what appears to be the offending code
and checking the time on the outer level. I've had similar problems
and spent lots of time examining a particular chunk of code only to
find out later that the caller was calling it a zillion times but the
routine was doing internal caching so debug code only executed once,
things like that.

If processor is going to 100%, that's a clue. You said mySQL, I don't
do mySQL myself, but from experience with other db's in the past I'd
look for possible locking snarls, where your code is waiting on a lock
it can't get.

Then there's the whole protocol issue. Is the code generating the
amount of data you think it's generating, or is it pumping out huge
amounts of stuff you didn't intend for it to generate and can't see on
the page.

You can get there, it's just a lot of work. I would suggest
forgetting the idea of finding an easy answer and getting to-the-bone
rigorous about debugging it. That doesn't mean you can't get lucky,
just that you can waste a lot of time pulling the handle on the
slot-machine before you do.

--
http://www.ren-prod-inc.com/hug_soft...action=contact
Reply With Quote
  #3 (permalink)  
Old 05-16-2006
Someuser
 
Posts: n/a
Default Re: PHP performance issue

You said a complicated page, now does that also mean large? how many bytes
is the resulting page including graphical elements if applicable?

Your time differencial measures the time it took PHP the HTML preprossor to
generate the html. It does not measure the time it takes to send the
information to the client nor the the time to render the html on by the
client. If you are using output compression / buffering such as apache's
gzip then the page will only begin to be sent to the client once the script
has finished and clears the buffer and not as it is generated.

I would start by sending the resulting php generated html as a static page
vs using PHP to generate the code and compare the times, do you see a
difference? If not, then PHP is not the bottleneck.

Cheers,
James


"DaveInPNG" <CTS-Subscriptions1@sil.org.pg> wrote in message
news:1146997102.185109.195250@u72g2000cwu.googlegr oups.com...
> CentOS 4.2, Apache 2.0, PHP 4.3.9, PHP loaded as a module
>
> I've got a fairly complicated page using MySQL that from the user's


> If I use microtime() at the top and the bottom of the code, it says the
> code takes 0.3 seconds.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:25 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0