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?
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.
I know this question already has an accepted answer, but there's much more you can do than just caching. For example:
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.
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.
Avoid CNAME records; prefer A records instead. CNAMEs often require multiple queries to resolve.
Use a robust, high-performance commercial service, such as UltraDNS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With