kalinga wrote:
On 8/4/05, Kristen G. Thorson <kthorson@xxxxxxxxxxxxxxxxxxxxxx> wrote:
kalinga wrote:
if you are quering a external host, the bad network conditions may
cause delay in results.
if your server is connected to a heavily loaded hub/ cheap switch, or
the target hosts DNS servers are poorly configured/ slow in responce
it adds further delay to your result.
try dig/ nslookup on your server for the target hostname/address, you
may experience the same delay as with the php function.
Thanks for the reply. The problem I had - and that I was trying to
briefly describe - is not quite explained by slow DNS lookup, at least
not so far. I have one script, run on the same machine:
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>
Running CLI again, host names are apparently cached, because then they
all return in .0005 seconds.
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
This will happen consistently, with less than 1/100 s variation in time
for each lookup.
Any DNS lookup tools are perfectly fast when run from the command line.
Also, other machines in the same subnet, using the same DNS servers,
using 99% same apache config files (I diff'ed 'em) run just as fast
under same apache/php version as they do command line. It's hard to
imagine what external DNS problem could exist that would affect only one
of our servers, and on that one, only apache/php and nothing command
line. Something else is going on, but my initial tries of
downgrading/upgrading both php and apache haven't made a different yet.
Perhaps you have another suggestion?
could you please mention the environment, i mean, the os, and the
versions of php? is it binary install or a compile?
All binaries - RH-packaged rpms.
Working version (takes < 1 second for each gethostbyname() call under
CLI and under apache):
# rpm -qa | grep php
php-odbc-4.3.2-23.ent
php-imap-4.3.2-23.ent
php-pgsql-4.3.2-23.ent
php-4.3.2-23.ent
php-ldap-4.3.2-23.ent
php-mysql-4.3.2-23.ent
# rpm -qa | grep httpd
httpd-2.0.46-46.ent
redhat-config-httpd-1.1.0-4.30.2
httpd-devel-2.0.46-46.ent
# uname -r -o -i -s
Linux 2.4.21-4.ELsmp i386 GNU/Linux
Not working (takes 5 seconds for each gethostbyname() call under apache,
but < 1 second under CLI):
# rpm -qa | grep php
php-imap-4.3.2-23.ent
php-4.3.2-23.ent
php-odbc-4.3.2-23.ent
php-mysql-4.3.2-23.ent
php-ldap-4.3.2-23.ent
php-pgsql-4.3.2-23.ent
# rpm -qa | grep httpd
httpd-2.0.46-46.ent
redhat-config-httpd-1.1.0-4.30.2
httpd-devel-2.0.46-46.ent
# uname -r -o -i -s
Linux 2.4.21-4.ELsmp i386 GNU/Linux
The function returns correctly, but it takes about 5 seconds every
time. After I run the script the first time on the "not working"
machine, it looks like the names are cached for the CLI, as they tend to
take only .0005 seconds to resolve.
Thanks for the help.
kgt