Can a long /etc/hosts file slow DNS lookup?

I'm facing a little question here. I have a long /etc/hosts file. (working in the web, so I'm hosting a lot of sites locally for developping). Let's says it is about 40, 50 lines long. All redirecting to 127.0.0.1.

Now when checking Chrome's inspector, it seems my local web pages are loading slowly because of the DNS Lookup part. On a mygreatwebsite.local url also defined in the /etc/hosts file.

After a quick check, it would seem that reducing the hosts file to a couple of lines, drastically speeds up the DNS lookup part. So my question, is it possible to be confronted with differences of about 5 seconds for 50 lines, and insignificant times for a couple of lines? Or am I completely missing something?


Your tld .local could be the problem, zeroconf uses this. There is no real standard, but the suggested tld for an internal tld is .site or .internal. See http://en.wikipedia.org/wiki/Top-level_domain#Pseudo-domains for this.


Can a long /etc/hosts file slow DNS lookup?

The answer is yes, in a Windows (XP/Vista/7) machine.

It is a known problem that a long hosts file does not work well with "DNS Client" service.

http://winhelp2002.mvps.org/hosts.htm:

in most cases a large HOSTS file (over 135 kb) tends to slow down the machine.

[Solution: Set "DNS Client" service to manual or disabled]

http://vlaurie.com/computers2/Articles/hosts.htm:

Note that a hosts file that is much over 100 KB can actually slow up browsing unless the service "DNS Client" is set to manual start.

www.ericphelps.com/scripting/samples/Hosts/:

The most important thing to do before using large HOSTS files is to disable the Domain Name Service client ("DNS Client" or "DnsCache") service on your machine. It sounds bizarre, but the DNS client isn't needed to do DNS. Worse, if you have a large HOSTS file (which is what I suggest), the DNS client chokes your entire PC.

... and I have personally witnessed this on three different Windows machines: XP Pro, Vista, and 7 Starter.