Tuesday, November 26, 2013

Know yourself when choosing the right web hosting 

    There are a lot of web hosting companies out there, many claim to have some sort of accelerators that can significantly speed up your web pages.  While some claims are true, it's better to put them to test.

    Recently I looked at a web hosting company,  found one of its customers by going to "testimonials" section and picked a "happy" customer.  When I opened this customer's site in my browser, I am surprised that it was not that snappy (despite the good words from the "happy" customer).

   To get a better measurement, I opened Chrome's developer console and clicked a new link.  The network tab in developer tool showed that the main HTML page itself (not including the resources like css, js, images ...) spent more than 2 seconds just in the "waiting" period.  To those who are not familiar with this term, "waiting" period is the time between transmission of the HTTP request and arrival of first byte of HTTP response comes. Interestingly, if I refresh the page, the waiting time is only a little more than 100ms.   The most likely reason is that data is cold in the database (not in the cache).

   What if I refresh the page multiple times and what would the waiting times be?   Since it's tedious to do it manually, I used a simple script (using netgend javascript syntax) to do the measurement.  Here the URL is changed to keep the web hosting company anonymous.
 function VUSER() {  
      i = 0;  
      while (i < 10) {  
           action(http, "http://www.example.com/somepage");  
           printf("%.2f\n", http.initialRespTime);  
           i ++;  
    It produced the following data (in ms):

    From this we can observe that:

  • After the first 2 attempts, the server is fairly responsive.  ~80ms is quite fast considering the network latency itself is about 40ms.
  • Occasionally the latency goes a little higher (like the 231ms in the above) but still acceptable, could be because server is busy handling other requests.

     We knew the (most likely) reason why the first waiting time is long, but why was the second waiting time is high too?   I couldn't think of a reason.  Even looked at packet capture when I ran the test and it confirmed the timing reported by test tool.  I can only guess that it's introduced by the acceleration engine of the web hosting infrastructure.

     Based on the numbers, we could see that the accelerator may be working, but does it help if you are a site owner? It depends:

  • If your web site is lightly visited,  your visitor may have a not-so-great experience (every page that he clicks will be cold in database).  The benefit of the accelerator may be questionable.
  • If your site is heavily visited,  majority of the visitors will feel your site is snappy!

     In summary, you, as a site owner, need to know your site before choosing the "right" web hosting service.

No comments:

Post a Comment