Other Software

ID #93

Why does your service seem slow?

Applies to: Grid System

Slow response time could be caused from several sources. You will need to perform some tests to see where it is coming from before reporting slowness:

  1. There could be congestion on the internet between you and us that slows down your connection to us. To determine whether this is the problem, perform a traceroute test as described in this other FAQ to figure out if you are just experiencing bad internet connectivity, and not a problem with any of our servers.

  2. If you determine from traceroutes that there is no network congestion or internet routing problem interfering with your connection to us, then check the following:

  3. If your FTP file transfers are slow, check all the advice found here.

  4. If you think your MySQL queries are slow, you should make sure that all JOINS are done correctly (that left joins are not done backwards with tables in the wrong order), that every column mentioned in the WHERE or ORDER BY clause of any SELECT query has a table index on that column, and that you have no VARCHAR type columns in any table. You can make table indexes on columns and change column types using the Onsite Control Panel. If your tables and queries are not optimized this way, then your queries will be hundreds of times slower than they would otherwise be.

  5. If you think any page on your website is slow, remove any references in your HTML code to objects (like images, banners, etc) that are hosted elsewhere. If that other host is slow or having a problem and your page tells a browser to load something from that other site, then that other site will cause your page to render very slowly or not at all.

  6. If you think your PHP driven website is slow, use the PHP stopwatch below to time the page's execution. Create a new file in the same directory as the slow webpage named timer.php and copy/paste the following into it:
    class BC_Timer{
    var $stime;
    var $etime;

    function get_microtime(){
    $tmp=split(" ",microtime());
    return $rt;

    function start_time(){
    $this->stime = $this->get_microtime();

    function end_time(){
    $this->etime = $this->get_microtime();

    function elapsed_time(){
    return ($this->etime - $this->stime);
    After you do that and save the timer.php file, edit the file of the webpage that you think is slow, and insert the following PHP code:
    # with a PHP open tag
    $timer = new BC_Timer;

    # All your pre-existing PHP code goes here

    # then at the end of the file, insert:
    echo number_format($timer->elapsed_time(), 3) . " seconds";
    Save the changes and reload that webpage. Even very complicated PHP pages should execute in less than a second.

    If your script is taking longer, move the $timer->end_time(); line closer to the beginning of the script (after the call to start timer), save changes, and reload/refresh the page, check the time it took to execute. Keep moving the call to stop timer lower and lower and rechecking until you get a dramatic jump in elapsed time. That will show you where you need to improve your php coding. If your time dramatically slows down after a MySQL query, see #2 above on how to speed up queries.

Last update: 2010-09-29 16:44
Author: FAQ Admin
Revision: 1.2

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 5 (2 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
If your webpage is making connections to external sites with javascript like:


or image tags like

img src=http://some-other-site/img.jpg

AND if that other external site is slow, is down, or is having any other problem, then it will cause your pages that link to that object to slow down while the browser is stuck trying to load the bad object from the other site.

This is because the browser is trying to fetch the off-site object in order to determine how to render the rest of your page. If the off-site object can't be reached, your page will load slowly or not at all.
Added at: 2003-06-28 19:48

Comment of Anonymous:
Some good sites to help figure out why your site is slow:


Added at: 2004-08-27 19:28

Comment of Anonymous:
intermediate times can be got through adding the following to the class -

function stopwatch() {
$this->ttime = $this->get_microtime();
return ($this->ttime - $this->stime);

and put
echo $time->stopwatch. " seconds";

anywhere in the script you want to check the intermediate time. The $timer->end_time() can then be left for the full script time
Added at: 2004-12-31 05:42