gethostbyname() time issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following script:

<?php
$url_array = array( 'http://www.imakenews.com/progresspsdn/e_rss.aspx',
                   'http://rssnewsapps.ziffdavis.com/eweekdeveloper.xml',
                   'http://itpapers.zdnet.com/xml/RSS-239.xml',
                   'http://rssnewsapps.ziffdavis.com/eweeklinux.xml' );
foreach( $url_array as $url ) {
 $rdf = parse_url($url);

 $timestart = microtime();
 $h = gethostbyname($rdf['host']);
 $timeend = microtime();
$diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4);

echo "gethostbyname(".$rdf['host'].") took $diff s and resolved to $h<br>\n";
}
?>


takes less than 1 second on CLI:

# php gethostbyname.php
Content-type: text/html
X-Powered-By: PHP/4.3.2

gethostbyname(www.imakenews.com) took 0.0010 s and resolved to 208.254.39.65<br> gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162<br> gethostbyname(itpapers.zdnet.com) took 0.1922 s and resolved to 216.239.113.159<br> gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162<br>



but takes 20 seconds under Apache 2.0.46:

gethostbyname(www.imakenews.com) took 5.0071 s and resolved to 208.254.39.65
gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162 gethostbyname(itpapers.zdnet.com) took 5.0097 s and resolved to 216.239.113.159 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162



The DNS server timeout was set to 5 seconds, but we changed it to 10, and it had no effect on either. My efforts to Google this has not lead me in very helpful directions thus far, since gethostbyname() is not actually failing - it just takes 5 seconds to return.

Even just a hint of where I might start looking will be much appreciated.



Thanks,
kgt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux