Slow website response? How can I fix this issue?

10,620

Solution 1

(I can't see your DNS figures on that page.) You can use a different DNS provider which provides a better service, you don't have to use the one that comes with your hosting or your domain name registrar.

Yes, it gets cached, so it's not every request.

Solution 2

Relocating the webserver to the US will hugely improve server response time for US users. Investing in better DNS servers will also improve response time, but only for the first request.

The following analysis shows where your speed bottlenecks are at present. (Short version: most of the 1-2 seconds is the time it takes to reach the webserver, not the DNS server.)

Time taken for domain lookup (DNS response)

To determine the speed of the DNS lookup from a computer based in the US, we can use the Unix 'dig' command, or a web-based dig service based in the US, which gives us this response:

; <<>> DiG 9.6.1-P1 <<>> scirra.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39135
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;scirra.com.            IN  A

;; ANSWER SECTION:
scirra.com.     3600    IN  A   84.45.57.143

;; AUTHORITY SECTION:
scirra.com.     165087  IN  NS  ns1.scirra.hypervserver.co.uk.
scirra.com.     165087  IN  NS  ns2.scirra.hypervserver.co.uk.

;; ADDITIONAL SECTION:
ns1.scirra.hypervserver.co.uk. 3600 IN  A   84.45.57.142
ns2.scirra.hypervserver.co.uk. 3600 IN  A   84.45.57.143

;; Query time: 489 msec
;; SERVER: 209.68.2.41#53(209.68.2.41)
;; WHEN: Mon Jul 11 09:17:57 2011
;; MSG SIZE  rcvd: 137

Note the "Query time: 489 msec". That tells us it took 489 milliseconds to resolve the domain name to the server's IP address (which does seem a little slow).

Time taken for server response

Next, we can check how long it takes to reach that IP address from a computer across the pond by using an online traceroute service based in Canada, which gives us the following output:

online traceroute

It takes about 730ms to reach the IP address of your server from Canada.

Conclusions and suggestions for improvement

Now we have enough data to make a conclusion. It's safe to say that the 1-2 second response time you're seeing is largely due to the fact that your server is so far away from visitors in Canada and the US. If a big proportion of your customers are in the US—and you should use your Google Analytics stats to determine this—you may wish to host the site on a server in the US rather than the UK. (You could also keep the UK server and route traffic to the nearest site using a geographical DNS service, but this might be overkill for a small site.)

You could also pay for DNS hosting with a US nameserver host such as DNS Made Easy in order to improve the initial lookup time. You're unlikely to improve it by more than around 300ms or so by doing this, so it might not make as big an impact as moving your server to the US, especially because the DNS lookup happens once per visit whereas page requests to the server are much more frequent, but using a fast DNS server is still worth doing.

Share:
10,620

Related videos on Youtube

Tom Gullen
Author by

Tom Gullen

Me Web developer. Contact Information Please DON'T contact me for help regarding any answers I provided! If it's suitable for StackOverflow, please post it on StackOverflow. For everything else I can be contacted on tomsotherone [insert the at sign here] googlemail () com

Updated on September 18, 2022

Comments

  • Tom Gullen
    Tom Gullen over 1 year

    I have pingdom monitor on my website:

    http://stats.pingdom.com/t68xhgex256f/375513

    For North America (big target market) the response time is 1-2 seconds. This is far too slow.

    Is there anything I can do? The server is located in the UK, so distance plays a big part I imagine.

  • paulmorriss
    paulmorriss almost 13 years
    It plays a part in the response time for the first time they check. It shouldn't be a large part. However as they're checking your site every 5 minutes it should be cached.
  • Tom Gullen
    Tom Gullen almost 13 years
    Thanks again, what causes a slow response time? Is it purely distance + DNS lookup? 1-2 seconds is far too slow for my site, I need it to be a lot faster :(
  • paulmorriss
    paulmorriss almost 13 years
    It could be page size or how busy the server is, how congested the bandwidth is at the hosting company. You can use a tool like YSlow to eliminate the first thing and see if it's one of the others.
  • Tom Gullen
    Tom Gullen almost 13 years
    I get 91 on Yslow, I've made sure it's as fast as possible! Primed cache page sizes are 4kb - 7kb as well! I'm going to rephrase/title the question
  • paulmorriss
    paulmorriss almost 13 years
    It looks like it's problems at the hosting end then. The fact that the response time is the same from the US and UK means that it's not likely to be a problem with distance.
  • LazyOne
    LazyOne almost 13 years
    UK has good dark colour. That's definitely a distance problem + your hosting may have slow line (or limiting the traffic) if it goes over the ocean. The best solution will be to have local USA/Canada-based server to target North American customers (maybe even 2 domains: .com and .co.uk) -- response time is important for customers.
  • LazyOne
    LazyOne almost 13 years
    @Tom I've checked your site from our USA server -- first request does take around 2 seconds .. but all other pages are very fast to load.
  • Tom Gullen
    Tom Gullen almost 13 years
    @LazyOne thanks! Does this mean is highly likely to be an initial DNS cache problem then?
  • LazyOne
    LazyOne almost 13 years
    @Tom 5 minutes is not a big interval at all .. and if their server flushes DNS resolve cache every time (or disallows caching altogether) these DNS records still should be cached at their ISP level. In any case -- considering my tests (1&1 hosted dedicated server) showing good speed for subsequent requests the DNS query time (DNS caching) is most likely to be the reason.
  • LazyOne
    LazyOne almost 13 years
    @Tom You have no issues with web part -- only DNS resolve time (at least that is what I'm making out of it). Consider moving your DNS to another company (or even another country) to have faster DNS response times. Also -- how www is declared -- A record or CNAME? If CNAME then consider re-doing it as A -- 1 less DNS lookup required.