Occassional "Waiting for response from" lag

As you can see from the test results, I have a pretty fast loading website.
http://www.webpagetest.org/result/131126_A0_H2A/

However, my assistant administrator randomly experience a problem when trying to load our website (raymond.cc).

He managed to capture this on video. What he did was refreshing the page and at 19 seconds of the video, he gets a “Waiting for response from raymond.cc” that last for a few seconds.

I understand that this problem can be caused by either the user’s computer or the server. “IF” this problem is caused by my server, may I know what is the possible cause?

It can’t be DNS because our website was previously using DynECT and now on EdgeCast Route. Both are enterprise grade DNS service that cost quite a lot of money every month.

Any ideas is much appreciated. Thank you.

DNS is probably cached by the browser, so that’s indeed an unlikely causehere , but then in these results (from a location a little closer to your web server) your DNS does appear to be slowing things down: http://www.webpagetest.org/result/131127_Q7_J3R/1/details/ Is there some CNAME chaining going on, perhaps? It’s generally better for performance to directly use your DNS provider’s nameservers.

A screencast is not as telling as WPT results, of course, but the browser appears to be waiting for the first byte to arrive on those reloads. Your server is in good health? Your keep-alive allowance is rather low at 5 seconds, setting up connections is expensive.

By the way, you’re serving duplicate headers:

[quote]HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Wed, 27 Nov 2013 11:55:44 GMT
Server: LiteSpeed
Accept-Ranges: bytes
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
ETag: “8cfb-5295dd15-7533aff6dc0cad8e”
Last-Modified: Wed, 27 Nov 2013 11:52:53 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 7020
Vary: Accept-Encoding, Cookie
Cache-Control: max-age=3, must-revalidate
Cache-Control: max-age=3

Expires: Wed, 27 Nov 2013 11:55:47 GMT[/quote]

Hey Rob,

I ran 9 tests from Los Angeles location (where my dedicated server resides) and only 1 has a pretty long DNS lookup time on my CDN.
http://www.webpagetest.org/result/131127_JA_RAC/2/details/

You may be right that the problem experienced by my assistant may not be DNS related because they are in milliseconds while he had to wait a few seconds to continue loading.

To confirm again, the “Waiting for response from” is actually waiting for the first byte, which means that the problem is probably from my dedicated server?

It could also be the client’s connection, i.e. your assistant’s, but then you’d expect he would experience this on other websites as well, not just yours. If it is your server, then there’s a whole array of possible causes.

The easiest way to get some insight into that (I find) is to monitor the server over time, paying attention to things like disk latency, memory usage and cpu load. If it’s a Linux server, something like Munin is fairly easy to install (there’s hosted service too, I believe).

Have to say it loads pretty quickly here, no matter how often I refresh your homepage. Can your assistance still reproduce this? If so, perhaps he can load the site with his browser’s Network tab open (ctrl+shift+i in Chrome) as those results can be helpful.

My assistant’s location is UK.

Took 6 seconds to load the first request which is raymond.cc/blog/
Weirdly Chrome does not show where the 6 seconds went to…

The problem seems to occur more frequently/often on our CDN (cachefly)

Ran a Website Performance Test at gomez.com with London location selected. Seems to have long first time byte time on a few files but not all of them.

One of the files hosted at CDN has 4 seconds of wait time.

One more test shows nearly 4 seconds of wait time on a CDN file.

Tried another website that also uses cachefly CDN and had 2 seconds of wait time.

Although it could be the CDN problem, but my assistant also experienced the lag on the first request loading the domain before even getting to the CDN…

The same happens when I open Chrome for the first time, or an incognito window. The first site I load takes significantly longer because Chrome is busy “Downloading proxy script”. The network tab looks much like the one you posted, so for that invisible wait-time you’re probably looking at a local issue (assistant’s computer, internet connection, proxy server, browser, virus scanner, etc).

As for those resources delivered slowly by your CDN: assuming that they have been pushed or pulled to the edge node(s) and they haven’t been purged or expired since, then your server has nothing to do with this, and they ought not to take so long.

Definitely something to run by your CDN provider.

raymond, if you can, I recommend installing something like New Relic on the server which will track the response times for all of the live traffic and let you see any outliers. You could also add response timings to your access logs and use something like logster + statsd + graphite to watch it (etsy has a lot of good blog posts on how they use it).

It’s possible that it’s being caused on the client side but it could also just be an intermittent problem on the server (lock somewhere, running out of available clients, etc).

For the CDN requests, do you push the content to your CDN or do you have it set up as a pull zone (where it hits your server for any content it doesn’t have cached)? If it is a pull configuration, make sure you have long cache times on the files but it’s possible that the long times are still caused by the origin server.

You have JS doing many things after the onload event.

The JS is doing very fugly things. I suspect poorly written JS.

One thing that may or not be an issue is multiple classes on the images. both class=“lazyload” class=" wp-post-image"

Looking at more of the tag it appears the image is supposed to be loaded with a JS lazy load.

Because the " wp-post-image" (the first character being a space is not good ) comes after the former “lazyload” the second class my take precedence in most Browsers. It is not easy to say for sure because it is a clear HTML error. I can only guess by thinking what I would do if I was writing the Browser code. Then the space in the second Class could cause issues too. Depends on how well the Browser and JS deal with it.

Here is where things get ugly. Possibly a mistake by the WP Theme programmer.

class=“lazyload” data-lazy-src=“http://static.raymond.cc/blog/wp-content/uploads/2008/03/anti-logger-capture-icon.jpg” class=" wp-post-image"

With the data-lazy-src= it appears to be a misguided attempt to copy jQuery’s data- tags. If the two classes are both necessary then they should be combined.

class=“lazyload wp-post-image”

In my opinion HTML should not be created by JS. The HTML for this page is essentially blanks to be filled in by JS. That is just WRONG. It is a very common practice, but when you have a mass of the blind leading the blind, it is still WRONG. Altering HTML with data- tags, backed with voluminous CSS files is a jQuery practice that should not be encouraged.

This page is generated by PHP. The PHP should be handling the Dynamic content, NOT JS.

All HTML and CSS for the page to render correctly should be in a static HTML doc or the script (e.g.) PHP shoudl generate all the necessary HTML and CSS.

I can build a prototype of an app in a manner of 2-3 hours. Have a functional working model in a day. At this point to the uninformed it appears the app is 80% complete. Just needs to be cleaned up. The opposite is true. The clean up is more than 80% of the job. This is the point were the programmer wants to move on to a new project rather than do the tedious necessitates of a project they have already become bored with. When the programmer is giving the code, plug-in, theme away for fee they are not going to do the necessary clean-up.

In the Word Press World this is the norm. If you doubt me just run the W3C validator tools on any WP theme demo site.

The part that is often missed is checking that the JS commands used are supported by all Browsers. JS is an imperfect programming environment. Due to the nature of the Browser environment it is not uncommon for Events to not be captured especially when using interval and .timeout commands are used. I assume this page use setTimeout in the onLoad event. In the Browser waterfall you will find activity the WPT does not see. About 250 milliseconds after page load you will see more HTTP activity. More HTTP activity when the page scrolls. All of this HTTP requests are requests made by scripting not the parser. When there is scripting activity when the refresh is clicked undesirable results commonly occur.