icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Shared Hosting » Anyone using fsockopen or curl for outside content seeing delays?

Shared Hosting Questions about your shared hosting account.

Reply
 
LinkBack Thread Tools Search this Thread
Old August 13th, 2007, 10:42 PM   #1 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
Anyone using fsockopen or curl for outside content seeing delays?

This is an off and on issue since around August 4th. My main page at http://www.markheadrick.com/main.php uses a Curl based function to get a random image from my Gallery and fsockopen to get my Blog's RSS feed to then parse.

When it is acting badly, the PHP execution time as shown at the bottom will be around 10 seconds or more when under normal situations should be around 2 seconds at most. The gallery image will timeout as well as Curl is set on a 5 second timeout.

With the troubleshooting I have done, I have narrowed the problem down to the amount of time it takes Curl or fsockopen to lookup the IP address of the supplied domain. For external sites, I can fix this delay by using the IP address instead of the domain. This is what I have done with my Nascar page when using fsockopen to Nascar's RSS Feed and Driver Standings.

I have created a test page here, which is a modified server status script that's been posted on here before: http://www.markheadrick.com/php/fsock_test.php

The code for the page is here:
PHP Code:
<?php
function getmicrotime() 

 list(
$usec$sec) = explode(" "microtime()); 
   return ((float)
$usec + (float)$sec); 

 
$start_time getmicrotime();
/*
*   +------------------------------------------------------------------------------+
*       CPANEL STATUS SCRIPT
*   +------------------------------------------------------------------------------+
*       Copyright Notice(s)
*   +------------------------------------------------------------------------------+
*       Disclaimer Notice(s)
*       ex: This code is freely given to you and given "AS IS", SO if it damages
*       your computer, formats your HDs, or burns your house I am not the one to
*       blame.
*       Moreover, don't forget to include my copyright notices and name.
*   +------------------------------------------------------------------------------+
*       Author(s): Crooty.co.uk (Adam C)
*   +------------------------------------------------------------------------------+
*/
// Configure script 
$timeout 1
$server_ip '';    // actual webhost server IP, leave empty to use localhost
$title 'FSOCKOPEN Timing Test';
// Set service checks
$p 1;  
$port[$p]    = 80;
$service[$p] = 'External Internet, google.com';
$ip[$p]      = 'google.com';
$p++;
$port[$p]    = 80;
$service[$p] = 'External Internet google.com ip, 64.233.187.99';
$ip[$p]      = '64.233.187.99';
$p++;
$port[$p]    = 80;
$service[$p] = 'Internal Internet, '.$_SERVER['HTTP_HOST'];
$ip[$p]      = $_SERVER['HTTP_HOST'];
$p++;
$port[$p]    = 80;
$service[$p] = 'Internal Internet, '.$_SERVER['SERVER_ADDR'];
$ip[$p]      = $_SERVER['SERVER_ADDR'];
 
//
// NO NEED TO EDIT BEYOND HERE UNLESS YOU WISH TO CHANGE STYLE OF RESULTS
//
?>
<html>
<head>
<title><?php echo $title?></title>
<style type="text/css">
<!--
span { background-color: Green; width: 2px; }
h2 { text-align: center; }
td, body
{
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8pt;
  color: #444444;
}
.status_header
{
  border-bottom: 1px solid #999999;
  width: 480;
  color: #3896CC;
}
.status_table
{
  border: 1px solid #333333;
  border-collapse: collapse;
  width: 480;
}
td
{
  border: 1px solid #333333;
}
.online
{
  background-color: #D9FFB3
}
.offline
{
  background-color: #FFC6C6;
}
-->
</style>
</head>
<body>
<br />
<center>
  <div class="status_header"><strong><?php echo $title?></strong><br />
  </div>
</center>
<br />
<table class="status_table" cellspacing="0" cellpadding="3" align="center">
<tr><th>Service</th><th>Status</th><th>Time to Check</th></tr>
<?php 
// Count arrays
$ports count($port) + 1;
$count 1;
while (
$count $ports)
{
    if (
$ip[$count] == '')
    {
        
$ip[$count] = 'localhost';
    }
 
$port_starttime getmicrotime();
    
$fp = @fsockopen($ip[$count], $port[$count], $errno$errstr$timeout);
    if (!
$fp)
    {
        echo 
"<tr>\n  <td>{$service[$count]}</td>\n  <td class=\"offline\">Offline</td>\n<td>".number_format((getmicrotime() - $port_starttime), 4)." seconds</td></tr>\n";
    }
    else
    {
        echo 
"<tr>\n  <td>{$service[$count]}</td>\n  <td class=\"online\">Online</td>\n<td>".number_format((getmicrotime() - $port_starttime), 4)." seconds</td></tr>\n";
        
fclose($fp);
    }
    
$count++;
}
//
// SERVER INFORMATION
//
?>
</table>
<br />
<center>
  <div class="status_header"><strong>Server Information</strong></div>
</center>
<br />
<table class="status_table" cellspacing="0" cellpadding="3" align="center">
<?php
// GET SERVER LOADS
$loadresult = @exec('uptime');
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/"$loadresult$avgs);
// GET SERVER UPTIME
$uptime explode(' up '$loadresult);
$uptime explode(','$uptime[1]);
$uptime $uptime[0] . ', ' $uptime[1];
echo 
"<tr>\n  <td>Server Load Averages</td>\n  <td>Past Minute: <b>$avgs[1]</b>, Past 5 Minutes: <b>$avgs[2]</b>, Past 15 Minute: <b>$avgs[3]</b></td>\n</tr>\n<tr>\n  <td>Server Uptime</td>\n  <td>$uptime</td>\n</tr>\n"
?>
</table>
<?php 
 
echo '<div align="center"><p>Current Server IP Address: <b>'.$_SERVER['SERVER_ADDR']."</b><br>\n";
 echo 
'Current Server Date/Time: <b>'.date ("l dS \of F Y h:i:s A T")."</b><br>\n";
 echo 
'Current Greenwich Mean Time: <b>'.gmdate ("l dS \of F Y h:i:s A T")."</b></p>\n";
 
$end_time getmicrotime();
 echo 
'<p>Total execution time: <b>'.number_format(($end_time $start_time), 4)."</b> seconds.</p></div>\n";
?>
</body>
</html>
It would be cool if someone could run this script on their server and tell me the difference in time between the domain and IP connections. I am wanting to see if this a local server/DNS issue or a wider network/DNS issue. I must also say that these delays do not seem to be related to the current server load.. well, unless the load is just real bad but then even regular pages are slow to load then. PHP4 and PHP5 both have the same problem.

Yes, I do have a ticket on the issue, NYY-990296 which management, Mike K, is aware of.

As a comparison of the good and bad:
http://www.markheadrick.com/images/s...ood_status.gif
http://www.markheadrick.com/images/s...147_status.gif

Anyway, I am just wanting to know what others are seeing on their server concerning this specific issue. Thanks!
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 15th, 2007, 5:08 PM   #2 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
I have been offline and haven't been able to check again until now; however, it seems as if the problem might have been solved according to the last responses from Raman and Mike K.

Raman: "...The issue is fixed. The problem was due to the resolver configuration having invalid entries..."

Mike K: "...We have modified the central dns settings on the server and have also added a few experimental testing changes..."

After a day or so I'll have myself convinced that it has been solved. Everything currently is running great. In any event thanks to all those whose efforts have gone into trying to crack this nut so far.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 15th, 2007, 7:59 PM   #3 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
Wish I could edit my post... the link to the bad status image above is wrong, this is the correct one: http://www.markheadrick.com/images/s...157_status.gif

Anyway, everything is still good, so here's hoping.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 17th, 2007, 11:49 PM   #4 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
Well.. it's baaack

http://www.markheadrick.com/images/s...748_status.gif

I wonder if all the cPanel upgrades to 11, email/SpamAssassin changes and what not may have broken the fix with the DNS configs. Anyway, ticket mentioned above has been re-opened.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 19th, 2007, 1:49 PM   #5 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,222 posts
Gave thanks: 18
Thanked 86 times
It seems that all of Saturday and so far today it's all working normal again.

Thanks to Ginsy in support for cleaning up the backup drive early this morning which was 100% full.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On