PHP5, MySQL5 & Apache2 on Debian Leny Slow

Discussion in 'Installation/Configuration' started by latheesan, Jan 5, 2011.

  1. latheesan

    latheesan New Member

    PHP5, MySQL5 & Apache2 Slow On Debian Leny VPS


    I am working on a simple API to retrieve some custom logs from my server.

    My server is a Debian Leny VPS with dedicated 2 Gb RAM and 1 dedicated core from host machine (which is about 2 Ghz atleast - last I checked).

    This is the script I am trying to run on my server:


    // Init
    $result_array = array();

    // Capture Data
    $log_type = isset($_GET['log_type']) ? intval($_GET['log_type']) : -1;

    // Proceed If Valid Log Type Requested
    if ($log_type 0)
    // Connect To MySQL Server

    // Query Database
    $result = @mysql_query(sprintf("SELECT * FROM `log_table` WHERE `log_type` = %d"$log_type));

    // Build Result
    if (@mysql_num_rows($result) > 0)
    $i 0;
            while (
    $row = @mysql_fetch_assoc($result))
    $result_array[$i]['log_id'] = $row['log_id'];
    $result_array[$i]['timestamp'] = $row['timestamp'];
    $result_array[$i]['log_text'] = $row['log_text'];

    // Close MySQL Connection

    // Return Result
    echo base64_encode(serialize($result_array));

    This is how i call my API from another server:


    // API Setting
    $api_url '';

    // Call The API
    $result file_get_contents($api_url .'?log_type=1');

    // Debug API Response
    echo '<pre>';

    When I run the api_test.php from another server to test the "log api", i get the response immediately. When I press F5 again (second time), the response is also returned immediately. When I press F5 for the third time, it takes about 30 seconds (give or take) to get a response.

    The response also slows down after fourth, fifth ... etc refreshes. However, if i wait a while and refresh the page, this behaviour starts over (first two response is quick, then it slows down).

    Is this an issue related to my PHP5, MySQL5 or Apache2 configuration? Or is it something to do with my script?

    Here is my server configs:

    apache2.conf -
    php.ini -
    my.cnf -

    Any idea..?
    Last edited: Jan 5, 2011
  2. falko

    falko Super Moderator ISPConfig Developer

    Are there any errors in Apache's error log?

    Is this an OpenVZ VPS? If so, what's the output of
    cat /proc/user_beancounters
  3. latheesan

    latheesan New Member

    Hi Falko,

    I checked the error.log and there aren't any significant errors that occured, besides the usual ones like these:

    As for the VPS system, no I am not using OpenVZ or Xen, it's Hyper-V running on Windows Server 2008 R2 Standard OS.

Share This Page