473,231 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

gethostbyname slow

using the gethostbyname function seems to noticeably slow down pages.
some of the comments in php.net's gethostbyname entry suggest using a
version that caches the result, but those versions also only speedup
subsequent calls to gethostbyname - the first call is still as slow as
ever.

so is there anything i can do to speed this up? perhapes i can just
implement a function equivalent to gethostbyname using fsockopen, or
something?

any help would be appreciated - thanks!

Jul 17 '05 #1
5 6558
On 6 Mar 2005 15:46:05 -0800, "yawnmoth" <te*******@yahoo.com> wrote:
using the gethostbyname function seems to noticeably slow down pages.
some of the comments in php.net's gethostbyname entry suggest using a
version that caches the result, but those versions also only speedup
subsequent calls to gethostbyname - the first call is still as slow as
ever.

so is there anything i can do to speed this up?
Are lookups slow from the commandline using 'host' or 'nslookup'? How slow is
slow? It's unavoidable that it'll take some time.
perhapes i can just
implement a function equivalent to gethostbyname using fsockopen, or
something?


Reinventing the wheel is probably the very last thing you want to consider -
name resolution involves communicating with other servers, so if it's just that
communication that's slow then reinventing DNS resolution code isn't going to
help.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

Andy Hassall wrote:
On 6 Mar 2005 15:46:05 -0800, "yawnmoth" <te*******@yahoo.com> wrote:
using the gethostbyname function seems to noticeably slow down pages.some of the comments in php.net's gethostbyname entry suggest using aversion that caches the result, but those versions also only speedup
subsequent calls to gethostbyname - the first call is still as slow asever.

so is there anything i can do to speed this up?
Are lookups slow from the commandline using 'host' or 'nslookup'?

How slow is slow? It's unavoidable that it'll take some time.


Lookups performed from the command line take 0 seconds, whereas lookups
performed with gethostbyname take 5 seconds. here's the php script i
used to determine this:

<?
$start = time();
echo `host google.com`.'(took '.(time()-$start).' seconds)<br>';

$start = time();
echo gethostbyname('google.com').' (took '.(time()-$start).'
seconds)';
?>

Jul 17 '05 #3
yawnmoth wrote:
Andy Hassall wrote:
On 6 Mar 2005 15:46:05 -0800, "yawnmoth" <te*******@yahoo.com> wrote:
using the gethostbyname function seems to noticeably slow down
pages. some of the comments in php.net's gethostbyname entry
suggest using a version that caches the result, but those versions
also only speedup subsequent calls to gethostbyname - the first
call is still as slow as ever.

so is there anything i can do to speed this up?


Are lookups slow from the commandline using 'host' or 'nslookup'?
How slow is slow? It's unavoidable that it'll take some time.


Lookups performed from the command line take 0 seconds, whereas
lookups performed with gethostbyname take 5 seconds. here's the php
script i used to determine this:

<?
$start = time();
echo `host google.com`.'(took '.(time()-$start).' seconds)<br>';

$start = time();
echo gethostbyname('google.com').' (took '.(time()-$start).'
seconds)';


My results running that script are:
google.com has address 216.239.39.99 google.com has address 216.239.57.99
google.com has address 216.239.37.99 (took 0 seconds)
216.239.57.99 (took 0 seconds)

which definitely does *not* reflect a 5 second execution time.

--
Virgil
Jul 17 '05 #4

Virgil Green wrote:
yawnmoth wrote:
Andy Hassall wrote:
On 6 Mar 2005 15:46:05 -0800, "yawnmoth" <te*******@yahoo.com> wrote:
<snip>
Lookups performed from the command line take 0 seconds, whereas
lookups performed with gethostbyname take 5 seconds. here's the php script i used to determine this:

<?
$start = time();
echo `host google.com`.'(took '.(time()-$start).' seconds)<br>';

$start = time();
echo gethostbyname('google.com').' (took '.(time()-$start).'
seconds)';


My results running that script are:
google.com has address 216.239.39.99 google.com has address

216.239.57.99 google.com has address 216.239.37.99 (took 0 seconds)
216.239.57.99 (took 0 seconds)

which definitely does *not* reflect a 5 second execution time.


I guess it's a problem with my server configuation, or something...

Any ideas as to what, specifically, is the problem? I haven't any...

Jul 17 '05 #5
TerraFrost wrote:
Virgil Green wrote:
yawnmoth wrote:
Andy Hassall wrote:
On 6 Mar 2005 15:46:05 -0800, "yawnmoth" <te*******@yahoo.com>
wrote:

<snip>

Lookups performed from the command line take 0 seconds, whereas
lookups performed with gethostbyname take 5 seconds. here's the php
script i used to determine this:

<?
$start = time();
echo `host google.com`.'(took '.(time()-$start).' seconds)<br>';

$start = time();
echo gethostbyname('google.com').' (took '.(time()-$start).'
seconds)';


My results running that script are:
google.com has address 216.239.39.99 google.com has address
216.239.57.99 google.com has address 216.239.37.99 (took 0 seconds)
216.239.57.99 (took 0 seconds)

which definitely does *not* reflect a 5 second execution time.


I guess it's a problem with my server configuation, or something...

Any ideas as to what, specifically, is the problem? I haven't any...


Nope. I wouldn't even try to diagnose someone's network problems like this
on a remote basis. I don't know enough to solve the problem in the abstract.
By the way, you can run the code on my server using
http://www.obsydian.com/gethostbyname.php

--
Virgil
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eric Brunel | last post by:
Hi all, I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I have one problem that I can't figure out: when I wanted to get "the" IP address of the current host with...
1
by: Fortepianissimo | last post by:
I've tried using socket.setdefaulttimeout(timeout) to set the default timeout to 'timeout' for all sockets. The part that's not clear to me, is that if this will affect...
5
by: ruroma | last post by:
Hello, I have one problem, and can think of two possible solutions but I can't manage to make them work. I'm open to other suggestions if you thik is better. The main function calls...
1
by: Glen Conway | last post by:
Hi, I'm trying to use the gethostbyname function from wsock32.dll and failing dismally Has anyone got a successful implementation of this in VB.NET? My ulitimate goal is to resolve NetBIOS names...
1
by: Quentin Carbonneaux | last post by:
Hello, I'm writing a little program which has to get a FQDN on his stdin and return the IP on stdout, we can do it easily with gethostbyname call but I would like to set up a timeout to this...
0
by: Ryan Liu | last post by:
Hi, I have problem to connect to database server from a windows 98 machine. I look at exception trace log, the problem seems not because of database driver itself. Seems the problem is...
1
by: yawnmoth | last post by:
I seem to be getting conflicting gethostbyname behavior on different servers. Before going into detail, here's the script I'm using: <? $address = $HTTP_SERVER_VARS; $rev =...
2
by: Andrew DeFaria | last post by:
I've been having problems with my ISP. One way it seems to manifest itself is that I can not reach or contact my ISP's DNS servers. IOW a simply nslookup google.com will fail. So I tried writing...
18
by: aj | last post by:
I have the following snippet of code. On some platforms, the delete calls works, on Linux, it core dumps (memory dump) at the delete call. Am I responsible for deleting the memory that...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.