[ale] /etc/hosts and caching

Michael H. Warfield mhw at WittsEnd.com
Fri Nov 4 10:02:31 EDT 2011


On Fri, 2011-11-04 at 07:40 -0400, Chesser.Damon wrote: 
> This dovetails into building a DNS caching server I asked earlier this
> week.  The issue is we are seeing latency in our application and a
> possible (but only possible, not proven) issue might be host lookups.  I
> figured that an entry into /etc/hosts would be faster than a WAN DNS
> lookup especially since the IP is static.  Someone was concerned with
> disk reads and that becoming a bottleneck.  Someone else pointed out
> that /etc/hosts file was cached.  

/etc/hosts file would be file cached in the disk buffers if nothing
else.  If you have a local cache, like nscd, then that's another layer
of caching.  Normally /etc/hosts file lookups are blindingly fast unless
the system is already overloaded or the hosts file is huge.  And, yes,
in the case of a static IP address, a hosts file will, most certainly,
be much much faster.

What kind of "latency" are we talking about here?  Maybe a more detailed
examination of what you are trying to do might help over and beyond
helping you with what you already think your solution might be.

Normally, if you have a normal local (to your network) recursive name
server latency should only come up on the first query after the cache
has expired (nominally 1 day).  After that, the response is going to
come from that network local nameserver.  It won't be quite as fast
as /etc/hosts but it will be much faster than a full recursive lookup
(and you can set that TTL to be much longer if the address is truly
static - weeks if you want).  A host local cacher will be somewhere in
between a network local cacher and the local hosts file for multiple
lookups (but, often slower on initial looks where more than one machine
may be looking a host up).

Is this application OpenSource?  Is it in C or a scripting language?  It
might be possible to use an async DNS resolver package and "pre-request"
the name resolution and cache it in the application itself.  That would
probably be the fastest solution, if, in fact, this is truly your
problem.

Are you having problems with other DNS lookups?  Certain kinds of
network misconfigurations can result in excessive DNS latency.  Use to
be we were seeing quite a bit of this with IPv6 incorrectly enabled.

If this address is truly STATIC static but a configuration variable from
a file, you might also try the hard coded IP address to test out your
latency problem and determine if it really is DNS lookups causing the
difficulties.

Regards,
Mike

> This started a google search by me to find out if that was true or not.
> Totally inconclusive.  Some have reported issues with not being able to
> get the Linux box to re-read the hosts file after a change was committed
> short of a reboot or init restart.  Others have said just make the
> change and it shows up.  I have not found any documentation saying
> whether it was cached or not.  Any smart guys know the answer or can
> provide any documentation on that?  It's kind of funny, you think you
> KNOW something until someone says "Prove it".
> 
>  
> 
> Damon at damtek.com 
>   
>   
>   
> LEGAL DISCLAIMER 
> The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. 
>   
> SunTrust is a federally registered service mark of SunTrust Banks, Inc. Live Solid. Bank Solid. is a service mark of SunTrust Banks, Inc. 
> [ST:XCL] 
>  
> 
> 
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo

-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
Url : http://mail.ale.org/pipermail/ale/attachments/20111104/0d8f8de1/attachment-0001.bin 


More information about the Ale mailing list