Tuesday, 20 April 2010

Performance improvement for DNS lookups

Wondered why companies like Google have their nameservers named like ns1.google.com ?, rather than ns1.SomeOtherCompany.com ? - its' a performance tweak, that I'll demonstrate with a detailed lookup as follows:

DNS speed check for www.google.com

Probing k.root-servers.net for 'A' record for www.google.com.

Refered to b.gtld-servers.net. [Time 426 ms]

Probing b.gtld-servers.net for 'A' record for www.google.com.

Refered to ns3.google.com. [Time 81 ms]

Probing ns3.google.com for 'A' record for www.google.com.

Found, 'A' record for www.google.com. [Time 111 ms]

See, three lookups, one for .com, the other for .google.com, and finally www.google.com

Now, compare that with freenameservers.co.uk, whose nameserver is not on the same domain

DNS speed check for www.freenameservers.co.uk

Probing k.root-servers.net for 'A' record for www.freenameservers.co.uk.

Refered to ns2.nic.uk. [Time 337 ms]

Probing ns2.nic.uk for 'A' record for www.freenameservers.co.uk.

Refered to ns1.telivo.com. [Time 84 ms]

Probing k.root-servers.net for 'A' record for ns1.telivo.com.

Refered to b.gtld-servers.net. [Time 366 ms]

Probing b.gtld-servers.net for 'A' record for ns1.telivo.com.

Refered to ns0.ai270.net. [Time 84 ms]

Probing ns0.ai270.net for 'A' record for ns1.telivo.com.

Found, 'A' record for ns1.telivo.com. [Time 97 ms]

Probing ns1.telivo.com for 'A' record for www.freenameservers.co.uk.

Found, 'A' record for www.freenameservers.co.uk. [Time 84 ms]

Six lookups in total, one for .uk, then .com then telvio.com, then ns1.telvio.com, then freenameservers.co.uk. then www.freenameservers.co.uk

So, in short, if you have the option, you should always have your nameservers named the same as your primary domain.

No comments: