1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Please help to fix my apache setting ?

Discussion in 'Apache' started by energetic, Sep 25, 2007.

Thread Status:
Not open for further replies.
  1. energetic

    energetic Well-Known Member

    Messages:
    2,844
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #21
    I try and Thanks.


     
    energetic, Oct 5, 2007 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #22
    The first place I would look is MySQL and luckily, MySQL keeps a log of slow queries. By default, any query that takes more than 2 seconds is logged in your mysql log directory in a file called mysql-slow.log although this filename may change depending on your setup.

    The mysql slow logs tell you the time the query ran, how long it took, how long it was locked for, which mysql user ran the query and what the actual query was.

    If you use the mysqldumpslow tool, it will aggregate all the queries that are the same and tell you how many times per day each slow query was run. You'd be surprised how often it's the 3 second query, not the 45 second query that is the real culprit because it's run 9000 times a day on the home page where the 45 second query is only run once an hour in a cron job...

    Lastly, we're all still guessing here and guessing doesn't guarantee to get you anywhere. You should add some code to your site to do some profiling. I have a simple example below.

    $timing = NULL;
    ...
    $timing['query1'] = Array('starttime' => microtime());
    $result = mysql_query("SELECT * FROM `blog` ORDER BY `date` LIMIT 10");
    $timing['query1']['endtime'] = microtime();
    ...
    $timing['loop1'] = Array('starttime' => microtime());
    while($row = mysql_fetch_array($result)
    {
      echo($row['blogpost']);
    }
    $timing['loop1']['endtime'] = microtime();
    ...
    echo("<!--\n");
    print_r($timing);
    echo("-->\n");
    
    PHP:
    You can be much more sophisticated than that example, such as adding all the queries together and printing a string like "This page generated in 0.5 seconds using a total of 12 queries." but it should be a good place to start from.
     
    Ladadadada, Oct 7, 2007 IP
  3. energetic

    energetic Well-Known Member

    Messages:
    2,844
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #23
    Ladadadada, thank you.
    But How to use your code ?
     
    energetic, Oct 7, 2007 IP
Thread Status:
Not open for further replies.