Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My website currently is running slow when doing certain AJAX calls. If I do the ajax action consecutively in a row, it is fine. But if I pause for a few minutes and then fire off the ajax event, the response would take a long time. The reason, according the the timeline, is DNS Lookup.

I'm currently using a DNS provider but could this also be a problem with my web app itself or Apache?

My app is running on the LAMP stack. This problem happens for different people. So it is probably not a problem with my local machine or browser.

See attached image for the timeline sample. The first post request took a long time but the subsequent ones were all below 1 second.

enter image description here

More Info:

I recently changed my vhost settings for apache using ServerAlias in an entry. Before the ServerAlias had it's own entry as a ServerName.

Before:

NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot /home/staging/www
  ServerName mydomain.com
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /home/staging/www
  ServerName www.mydomain.com
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /home/staging/www
  ServerName test.mydomain.com
</VirtualHost>

Now:

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot /home/staging/www
  ServerName mydomain.com
  ServerAlias www.mydomain.com test.mydomain.com
</VirtualHost>
share|improve this question

2 Answers 2

You might check into the TTL of the remote DNS record(s) to see if "they" are set too "aggressively" versus your exceptions/needs.

share|improve this answer
    
It was set at 600. What's considered agressive? –  samxli Jul 15 '11 at 12:05
2  
Agressive is anything smaller than what you need. –  womble Jul 15 '11 at 12:08
2  
How frequently do you need to change them? How long is it acceptable that a DNS lookup points to an old IP address after a change? How long in advance do you know that you will need to make a change? Once you have the answers to those questions, picking a number of seconds for the (default) TTL should be not-too-hard. I've seen TTLs in the region of 3600-86400 work fairly well (that allows a client to cache the lookup for 1h-1d) and if you know you have a change coming up, you can always push the TTL down to 600-or-so 1.5 (default) TTLs before you do the change. –  Vatine Jul 15 '11 at 15:57
    
In this case, if the TTL results in your DNS cache dropping it before the next cycle of your application, then your application will trigger another lookup - possibly directly contributing to the DNS performance you are seeing. There are DNS caches which can override the TTL with a programmable value. –  user48838 Jul 15 '11 at 17:33
    
And those DNS caches need to hunted down and killed, along with the morons who installed them. –  womble Jul 15 '11 at 22:26

DNS TTLs, as user48838's answer suggests, is something definitely worth looking at. However, if they're set appropriately, you might want to look at your "DNS provider". I mean, I can setup a couple of DNS servers at the end of a DSL line in lower Krakowskia and hang out a shingle as a DNS provider, but that doesn't mean that it's any good.

I'm a bit cynical of DNS providers in general; it's not a hard service to provide in-house, and you can get a lot more control over your DNS service if you manage it yourself. There's no doubt that if you need global, low-latency, high-availability service, a good-quality anycasted service could do the job, but by gum they're expensive, and I'm not getting the impression that you're doing the service provision for a large-scale website.

So, I'd be taking a really close and careful squint at your "DNS provider", and unless you can really convince yourself that they're not the source of the problem, either get a better one, or just bring it in-house, so you can at least manage the quality of service and ensure that it meets some minimum standard.

share|improve this answer
    
Would I need a dedicated server just for an in-house DNS? Or could this run on top of my current webserver? –  samxli Jul 15 '11 at 10:42
    
You should be easily able to run a DNS server alongside your webserver. –  womble Jul 15 '11 at 10:44
    
Along the thought, you might change up your current DNS server in use to see if there are any immediate performance improvements. –  user48838 Jul 15 '11 at 10:53
    
Strange thing is, I have a few domains being handled by the same provider, just one of the domains have been showing the symptom of the slow DNS Lookup. –  samxli Jul 15 '11 at 12:06
    
Where do I get started to run my own DNS? I'm on Centos 5 right now. –  samxli Jul 15 '11 at 12:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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