Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What algorithms do DNS servers use for faster lookups?

DNS servers have to be fast in order to avoid latency. What algorithms do DNS Servers use to reduce latency? Are they any caching mechanisms that could be effectively used to improve speed?

like image 816
Prabhu R Avatar asked Oct 18 '09 16:10

Prabhu R


2 Answers

Latency is a huge problem with DNS. The slowest part of DNS is reaching out across the 'Net and querying other servers. Any caching a client or server does will speed up the process. In fact, that's exactly what happens.

When a DNS server responds to a query, the answer comes back with a TTL (time-to-live). The TTL value tells the querying server how long to cache the response. The TTL value is set by the authoritative server for the zone. Typically it's about a day, but can vary depending on how often the administrator thinks the DNS entry might change.

The DNS client (which might be another server acting on behalf of an end user) caches the response and will flush it out of its cache when the TTL has been exceeded. Until that time, subsequent queries for that particular hostname will come out of the cache.

I used to run my own DNS server at home so all my computers on my LAN could take advantage of the local cache. But I discovered that it was better to use my ISP's DNS servers. They benefitted from the queries of thousands of customers and were much more likely to have more cached answers than my servers ever could.

like image 110
Barry Brown Avatar answered Nov 15 '22 01:11

Barry Brown


I know this question already has an accepted answer, but there's much more you can do than just caching. For example:

  1. Use BGP to establish a network of geographically distributed servers, reachable via Anycast. This can reduce the average number of hops that a DNS query packet has to traverse.

  2. Eliminate latency-containing infrastructure. For example, host your DNS servers with your ISP or at a large Internet peering point instead of at the slow end of a WAN.

  3. Avoid CNAME records; prefer A records instead. CNAMEs often require multiple queries to resolve.

  4. Use a robust, high-performance commercial service, such as UltraDNS.

like image 37
RickNZ Avatar answered Nov 15 '22 02:11

RickNZ