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.
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>
You might check into the TTL of the remote DNS record(s) to see if "they" are set too "aggressively" versus your exceptions/needs.
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.