Please help troubleshoot site slowness

I have a web site which is written in PHP + Zend + JQuery.

The landing page takes 1.6 - 2 sec while it loads very little data from the DB, so no heavy DB queries.

I see in FireBug that the main request takes 1.5 or 2 seconds, while the rest of the scripts/images/csss are loaded after this

site hosted on hostmonster, shared hosting.

how can I troubleshoot it at what level I have a delay?

I can’t publish the site’s URL, but I will PM it to you so you can check it in FireBug

I’ll buy you a beer if you could help me :slight_smile: seriously

Thank you very much

From my 20+ years as a Professional Webmaster, there’s alot of things that can cause problems like that, but why would you look at it in Firebug instead of Firefox and other browsers instead? Send the URL to me in a PM and I’m quite positive I can zero in on your problem quickly and hope you have the experience / knowledge to correct the problem(s).

With 20 years+ as a professional webmaster no doubt you would have heard of the Firefox extension “Firebug”? :stuck_out_tongue: It’s the leading website diagnostic tools for developers and has been so for 3-5 years.

A very simple technique is to sprinkle some echo lines through your code, displaying the elapsed execution time.

You can use PHP’s microtime call() to gauge this with a little more accuracy.

If you want to get more serious, there are libraries that assist with execution profiling, so that may be an alternative - but in your case, probably overkill at the moment.

I’ve enclosed a first stab at a simple function that you can call throughout your code to show elapsed time between various parts - should make it very easy to see where most time is being used. Apologies in advance for any syntax or other errors - but it should be enough for you to get the idea!

Although, I have to say, 1 second or so isn’t that slow!

I’d also check ping time to the web host - that may be a part of the delay.

function log_time_elapsed($msg = '')
    static $microtime_start = null;
    list($u, $s) = explode(' ', microtime());    
    if($microtime_start === null)
        $microtime_start = $u;
        return 0; 
    list($u, $s) = explode(' ', microtime()); 
    $diff = $u - $microtime_start;
    $microtime_start = $u;   
    if (! empty($msg))
         echo "$msg: elapsed microsecs $diff <br>\
    return $diff; 

// example use:
log_time_elapsed(); // first call initializes

log_time_elapsed("before db access");

// do db access ...
// ...

log_time_elapsed("after db access");

Yes brianoz; I know all about Firebug and don’t use it because it doesn’t show everything I need to know about a website. Your suggestions and PHP code to the original poster are correct and done nicely.

yslow is another option - also Google has a speed profiling plugin …

Let us not forget that Hostmonster is a well-known overseller. Server performance tends to suffer with oversellers–all of them. You can’t promise “unlimited” resources to everyone for very little money. Search for “hostmonster slow” and you’ll find other similar complaints.

Frequent outages

We have several domains with Hostmonster. We are based in Australia. During our night (USA daytime) our sites load very slowly and sometime not at all.

Lots of bad reviews of Hostmonster. There is a reason people recommend staying away from oversellers.