#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,670
    Rep Power
    171

    Website suddenly gone slow!


    Hi;

    This site I have has been working fast since 2008 this morning its gone slow. Takes 10 seconds till load the page.

    The server guys say Database and web server are working just fine.

    Whats the process of detecting the issue?

    I havent changed anything there.

    Thanks
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Use a debugger or download yslow (firefox extension) to start. If that doesn't reveal anything, scatter timing and logging functions throughout your code to time various loops and queries and try to narrow it down.

    Your sig is the worst joke I've read in months. Well done.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,670
    Rep Power
    171
    Originally Posted by ManiacDan
    Use a debugger or download yslow (firefox extension) to start. If that doesn't reveal anything, scatter timing and logging functions throughout your code to time various loops and queries and try to narrow it down.
    Yslow didnt reveal anything. Its strange because I have other sites on the same server connecting to the same database and they all work fine. Would you please give me some tips on loggin functions and timing tools?

    Originally Posted by ManiacDan
    Your sig is the worst joke I've read in months. Well done.
    Is it because it's is deprecated as of PHP 5.5.0, and will be removed in the future?
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    I actually recommend using Chrome's Network tab for debugging performance issues rather than Yslow. Yslow is OK if you want to get an overall picture of optimizations you can make, but if you're trying to track down a specific problem Chrome's interface is better.

    Assuming that the problem is not a client side issue, the time value that you're most interesting in is the "waiting" value, as that represents the amount of time that the server took processing the request for the resource.

    If you review the network inspector and determine that it's the initial HTTP request (for the PHP file) that is taking a significant amount of time, then it's time to dig into the PHP code for the site itself and determine why. You might find that it's something else, like a third party JavaScript library, instead.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Chrome's network tab is what I use, but YSlow is designed specifically for this.

    OP: Use microtime() repeatedly throughout your code to time various sections.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    YSlow or Chrome's Network tab, the only value you'd get out of either one is confirming that it's the server taking ~10 seconds to deliver the response. Neither of them are going to help you figure out WHY it's taking the server that long.

    Another method of confirming that would be to simply load your site from the command line if you have SSH/telnet access to where it's hosted. That also gets your webserver completely out of the equation.

    But I think this will come down to debugging.

    I really wish I had access to my server right now since I could share a debug class I wrote, but basically write something like this:

    PHP Code:
    function timer($message){
        global 
    $last;
        
    $now microtime(true);
        if ( empty(
    $last) ){ $last $now; }
        print 
    "$now (+".($now-$last).") $message\n";

    Adjust the output as needed, whether you're outputting to command line or through HTML.

    Then at various points of your code:
    PHP Code:
    timer("Identifier of where we're at in the code"); 
    The end result will be outputs showing the time at certain points in the code, as well as how much time as elapsed since the last timer() call.

    As you get more familiar with handling these kinds of issues, implementing debugging solutions like this will become second nature. In my systems today I have calls like the one above around database queries, listener callbacks, some method calls, etc., all standing by for me to flip a switch to display them all. I also use them to track key variables, memory usage, etc., as a program progresses.
  12. #7
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    YSlow or Chrome's Network tab, the only value you'd get out of either one is confirming that it's the server taking ~10 seconds to deliver the response. Neither of them are going to help you figure out WHY it's taking the server that long.
    The application my company develops makes more than 50 web requests to render. If one of them takes 10 seconds, or if ALL of them take 0.2 seconds, that's something that yslow would be able to tell me. We've moved well beyond the days when a website takes a single call to a single script to render. Without intimate knowledge of OP's setup, we have to assume he's like every other site and he makes repeated calls from the browser to his server for every single "page" on his site.

    Another method of confirming that would be to simply load your site from the command line if you have SSH/telnet access to where it's hosted. That also gets your webserver completely out of the equation.
    This assumes no webserver-level configuration is necessary (like mod_rewrite or any bootstrapping) and also assumes the problem isn't related to subsequent calls to ajax, css, or media content.

    I really wish I had access to my server right now since I could share a debug class I wrote, but basically write something like this:
    This functionalizes a previous suggestion, but it's a good start
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  14. #8
  15. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by ManiacDan
    The application my company develops makes more than 50 web requests to render. If one of them takes 10 seconds, or if ALL of them take 0.2 seconds, that's something that yslow would be able to tell me. We've moved well beyond the days when a website takes a single call to a single script to render. Without intimate knowledge of OP's setup, we have to assume he's like every other site and he makes repeated calls from the browser to his server for every single "page" on his site.
    Chrome would tell you that, too. But the base page will always be the first to load. The browser won't even know what else to load until that's loaded. And while AJAX might be more heavily used to build the page a piece at a time I think the interpretation is very safe that the OP was referring to the base page load. He didn't imply anything about AJAX or partial loading.

    This assumes no webserver-level configuration is necessary (like mod_rewrite or any bootstrapping) and also assumes the problem isn't related to subsequent calls to ajax, css, or media content.
    Exactly the point. We're trying to identify where the problem is and we're doing so by process of elimination. Bypassing the webserver eliminates a lot.
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Chrome would tell you that, too. But the base page will always be the first to load. The browser won't even know what else to load until that's loaded. And while AJAX might be more heavily used to build the page a piece at a time I think the interpretation is very safe that the OP was referring to the base page load. He didn't imply anything about AJAX or partial loading.
    He said his site was slow. You interpret that to mean "the round-trip and execution of my base PHP file which then subsequently kicks off all other processes is slow." I interpreted it as "my site is slow." His site is slow and that's all we know. I'm going to go into a Seuss fugue if I discuss this more.

    Exactly the point. We're trying to identify where the problem is and we're doing so by process of elimination. Bypassing the webserver eliminates a lot.
    Bypassing the webserver also stops most web apps from functioning at all. Accessing index.php and having it throw "no ID specified" tells us nothing.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  18. #10
  19. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by ManiacDan
    He said his site was slow. You interpret that to mean "the round-trip and execution of my base PHP file which then subsequently kicks off all other processes is slow." I interpreted it as "my site is slow." His site is slow and that's all we know. I'm going to go into a Seuss fugue if I discuss this more.
    Then you're assuming it's an application far more complex than what is normally asked about here, and far more complex than anything I've ever seen the OP speak of.

    I err on the side of conventional applications lest there's indication of complexity. No reason to complicate something that needn't be complicated.

    Bypassing the webserver also stops most web apps from functioning at all. Accessing index.php and having it throw "no ID specified" tells us nothing.
    I disagree with this very strongly. Some web apps? Sure. Most? No way. Most PHP applications don't require rewrites or webserver-level trickery, and most that include user logins still do something without them.

    Besides, hitting index.php (or another endpoint) is just the lowest common denominator of CLI testing. Pursuing that possibility could lead to the discovery of a suite of test scripts for unit testing, etc. And if it doesn't we'd at least have the opportunity to suggest the creation of such scripts for situations like this.
  20. #11
  21. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,670
    Rep Power
    171
    Hi guys, thanks;

    Everything started working fine again!

    The server people said they do not know what it was!
  22. #12
  23. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Bugs that go away on their own come back on their own. Insert some timing and logging code now so you'll be notified when it happens next time.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    14
    Rep Power
    0
    hi gamin


    Some of the common reason for a site to run slowly include:

    The number / size of external resources included in the site;

    Images not re-sized to their visible size;

    The database queries executed while the site loads.

IMN logo majestic logo threadwatch logo seochat tools logo