Why are my DNS Lookups so long (300+ms) when accessing my web site?

Solution 1:

Any call to a DNS name requires a lookup, even if it's local, so that part is expected. However, it should cache the record for as long as the TTL, so as long as you are using the name DNS name for all of your objects on the page, it shouldn't have to do the DNS lookup multiple times. You don't happen to be using unique cnames for each object on the page?

Check the TTL setting for your zone to confirm that it's set to something reasonable.

As for the longer times, it could be from either the DNS server or the DNS client. Try testing using nslookup to do DNS queries directly against the DNS server to see if you get the same response time. You may want to walk the domain name path from the TLD down to your domain name (or cnames) to see where it slows down.

A way to rule out (or in) your DNS client is to watch a public site like google.com with firebug to see if it is also slow.

Solution 2:

I had a very similar problem and solved it. It was a problem with our iptables configuration, which I understand was custom in-house, so you probably don't have the same problem but I thought I would link it up just incase.

Only receiving one document at a time from new web server

"Removing -m limit --limit 1/s from our iptables configuraton solved the problem presented."