-1

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>
samxli
  • 203
  • 1
  • 3
  • 11

2 Answers2

1

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

user48838
  • 7,393
  • 2
  • 17
  • 14
  • 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
  • That's purely your personal opinion. There may be instances where is it perfectly fine when it is not unleashed on unsuspecting folks by others who equally do not understand what they are attempting to do. – user48838 Jul 16 '11 at 01:54
1

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.

womble
  • 95,029
  • 29
  • 173
  • 228
  • 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
  • So stick your domains through http://squish.net/dnscheck, and maybe http://dnsstuff.com/ and see if any differences are reported between the domains; it's possible this one domain is misdelegated or something. – womble Jul 15 '11 at 12:10
  • Questions should go in questions, not comments. – womble Jul 15 '11 at 12:11
  • Nothing out of the ordinary came out when I did the squish.net/dnscheck. Is it even remotely possible that this DNS Lookup problem could be caused by my own server (apache in particular)? – samxli Jul 15 '11 at 17:14
  • Another thing I don't understand is why is it fast after the first slow-down? and then slows down again after I don't interact with the site for a while. Is this some type of caching going on in my browser? – samxli Jul 15 '11 at 17:19
  • Your "sometimes fast/sometimes slow" issues are because of DNS caching. Your web server can't cause slow DNS lookups, it's not involved at all. It's possible that your upstream resolvers are dead slow, too, but it's extremely unlikely if you don't have consistently slow resolution across all domains. – womble Jul 15 '11 at 22:25