2

It takes about 20-120 milliseconds for DNS (Domain Name System) to resolve IP address for a given hostname or domain name and the browser cannot do anything until the process is properly completed.

Before a browser can establish a network connection to a web server, it must resolve the DNS name of the web server to an IP address. Since DNS resolutions can be cached by the client's browser and operating system, if a valid record is still available in the client's cache, there is no latency introduced. However, if the client needs to perform a DNS lookup over the network, the latency can vary greatly depending on the proximity of a DNS name server that can provide a valid response.

So... how to / is there any way to reduce this DNS lookups through some server-side optimization or something else? Am i helpless here or it depends on size of web page / my hosting provider?

  • Have you tried benchmarking against another service such as Google DNS? In nginx for example its resolver 8.8.8.8 8.8.4.4 valid=300s; – dhaupin Sep 1 '16 at 20:59
3

The DNS lookup takes place well before the client has started reading the web page, so don't worry about page size. Remember that DNS is basically the process of translating a domain name to an IP address, so myexample.com --> 123.45.678.9, and this translation has to happen before the page itself can be requested from the IP address. The page could be tiny or extremely large, and the DNS lookup will take the same time.

So if you want to reduce DNS lookup times, you should make sure there's a very reliable DNS server not far from the client. That could mean:

  • Hosting your DNS separately from your registrar or regular web host. There are dedicated providers of DNS hosting, like DNS Made Easy and Dyn.com. These services will operate a globally-distributed network of DNS servers, so that the lookup can be answered as close to each client machine as possible. And (the theory goes), because they're only running DNS, they actually invest in that infrastructure and care about it being reliable (as opposed to some registrars we could name).
  • Hosting your own DNS servers. Be sure to fully understand it first though. You'll need a couple of VPSs in order to keep the service redundant. All these servers will do is handle DNS queries, and you can set about optimising their performance to your heart's content, beginning by installing something like PowerDNS, tinydns, or BIND.

Personally, I wouldn't encourage you to host your own DNS servers unless you really know what you're doing, and have a strong reason for doing so. In almost all cases, the relatively low cost of dedicated DNS hosting with one of the providers I mentioned will make that the better choice.

0

Usually every DNS resolver like Bind has a DNS cache. if x.x.x.x is my DNS server, when i type

 dig A averyuncommonebsite.com @x.x.x.x

i get first 2 figures for the response time. Then, the second time i i request it, i get an answer in 1ms because the response is in the cache of my DNS resolver which is BIND. So you may build up your own DNS resolver to have control on the DNS response time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.