Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 5th January 2011, 18:13
latheesan latheesan is offline
Junior Member
 
Join Date: Dec 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy PHP5, MySQL5 & Apache2 Slow On Debian Leny VPS

Hi,

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:

log_api.php
PHP Code:
<?php

// 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
    
@mysql_connect('localhost''USERNAME''PASSWORD');
    @
mysql_select_db('DATABASE');

    
// 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'];
            
$i++;
        }
    }

    
// Close MySQL Connection
    
@mysql_close();
}

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

?>
This is how i call my API from another server:

api_test.php
PHP Code:
<?php

// API Setting
$api_url 'http://www.domain.com/log_api.php';

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

// Debug API Response
echo '<pre>';
print_r(unserialize(base64_decode($result)));
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 - http://pastebin.com/y8rSV0em
php.ini - http://pastebin.com/Z3N86rKS
my.cnf - http://pastebin.com/uP2t8Rvw

Any idea..?

Last edited by latheesan; 5th January 2011 at 18:31.
Reply With Quote
Sponsored Links
  #2  
Old 6th January 2011, 15:08
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

Are there any errors in Apache's error log?

Is this an OpenVZ VPS? If so, what's the output of
Code:
cat /proc/user_beancounters
?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 6th January 2011, 17:09
latheesan latheesan is offline
Junior Member
 
Join Date: Dec 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Hi Falko,

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

Quote:
[Wed Jan 05 20:50:36 2011] [error] [client 62.193.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind
[Wed Jan 05 21:03:09 2011] [error] [client 89.36.xxx.xxx] File does not exist: /var/www/webdav
[Thu Jan 06 00:08:03 2011] [error] [client 82.111.xxx.xxx] File does not exist: /var/www/fastenv
[Thu Jan 06 03:48:48 2011] [error] [client 193.252.xxx.xxx] File does not exist: /var/www/phpMyAdmin
[Thu Jan 06 08:02:00 2011] [error] [client 58.218.xxx.xxx] script '/var/www/proxyheader.php' not found or unable to stat
[Thu Jan 06 08:52:30 2011] [error] [client 89.136.xxx.xxx] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind
[Thu Jan 06 11:23:20 2011] [notice] caught SIGTERM, shutting down
[Thu Jan 06 11:23:21 2011] [notice] Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch configured -- resuming normal operations
[Thu Jan 06 11:23:29 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 11:23:29 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 11:23:32 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 12:05:05 2011] [error] [client 58.218.xxx.xxx] script '/var/www/proxyheader.php' not found or unable to stat
[Thu Jan 06 13:16:25 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 13:16:25 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 13:16:28 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 15:44:14 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 15:44:14 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
[Thu Jan 06 15:44:15 2011] [error] [client 80.168.xxx.xxx] File does not exist: /var/www/favicon.ico
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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 17:26
[debian 5 + ispconfig 3] Unable to send mail tanakskool HOWTO-Related Questions 6 4th November 2009 18:20
Upgrade to php 5.2 in suse 10.1 gimhan90 Installation/Configuration 3 1st January 2009 20:32
Bind Failed christoph2k HOWTO-Related Questions 4 28th April 2007 00:57
e-mail problem!!! Debian 3.1 maroonworks Installation/Configuration 18 6th December 2005 14:42


All times are GMT +2. The time now is 14:56.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.