October 18, 2017

Understanding – Time to First Byte

Introduction

I faced slow website loading in a Tools for Testing TTFBproject and I am sure many of you must have faced the same. Now-a-days, people are worried about responsiveness of web server and speed of their websites. There are many reasons as to why your website might be slow! Typically, the most common reasons are inappropriate hardware configuration, incorrect coding practises, slow internet connection and so on. Apart from these, there is an overlooked but highly important factor that degrades the performance of your site and that is TTFBTime to First Byte.

What is TTFB?

TTFB – Time To First Byte, is a metric to measure responsiveness of web server and speed of website. In simpler words, it is the time any browser has to wait for the first byte to be received. TTFB is not the only metric to measure the speed of your site. In spite of this it cannot be overlooked.

Organizations make use of TTFB to identify the weak points like speed of their website when they make http request. By identifying the weak points, they know whether it is a server configuration issue or an application issue etc.

Following is the illustration of TTFB seen in Chrome Developer Tools. There are also various other components in the image below starting sequentially is Request Sent, TTFB and Content Download of the website.

The Request sent to the server took 0.16 ms which is acceptable. Then there is a waiting time for the content to be downloaded. This waiting time is TTFB where we receive the first byte of the response. So TTFB is the first thing that we have received before the content is downloaded and TTFB for current site request is 2.85 seconds which is huge. Finally, the content of website like CSS, images and scripts and so on, are downloaded in 8.55 ms which is also acceptable. So we can easily understand from the image below that TTFB is the first byte that we receive even before the content is downloaded.




Tools for Testing TTFB

There are various tools available online to test the performance of your site. Testing the performance of your site is indirectly, nothing but measuring TTFB. Following are the free tools you can use to measure TTFB of your site:-

  1. WebPageTest
  2. Google Chrome – Developer Tools (this is recommended as it is default integrated with Google Chrome Browser)
  3. Pingdom
  4. KeyCDN

TTFB Impacted by/Causes of High TTFB

TTFB is impacted by many factors, there are reasons as to why your TTFB is high. Following are some of those reasons:-


1. Server Configuration
The first thing that hits us is inappropriate server configuration. Off course, inappropriate server configuration is one of the major reasons to high TTFB. If your server configuration is inappropriate it will affect the performance of your site. It can make the processing of any request slow which will in turn result in high TTFB and the performance of your site will degrade.

2. High CPU Usage
Even if your server configuration is good your site might perform slow. Reasons to high TTFB are innumerable, one of which is High CPU Usage. If the CPU usage of your server is high it might degrade the performance of your site. Your server will not be able to process your requests quickly.


3. Slow Database Request
Slow Database Request is also one main reason for slow performance of your site. If your database is not structured well(indexes) or your query is not well-formed, then it will for sure add some delay in execution and will result in slower performance of your site.

4. Inefficient code on server
One of the main reason for slow performance of your site is inefficient code. Inefficient code will slow down the execution of your application and also will ultimately increase the CPU usage which will result in slow performance of your site. So, it is recommended that you always use best coding practises for your application.


Effect of TTFB

TTFB strongly affects the search ranking of your site. If TTFB of your site is high then it will affect the ranking of your site by not listing it at the top when searched. So the ranking of your site is directly linked to TTFB of your site. Though TTFB is not the only metric of low ranking of your site, however, it plays a major role in ranking of your site.


Improving TTFB

Improving TTFB can greatly help you increase the performance and speed of your site. Improving TTFB is nothing but reducing the TTFB number i.e. if the TTFB of your site is 4 seconds then you can improve TTFB of your site to 1 second. Following are the ways you can improve TTFB of your site:-


1. Improve your server configuration
Good server configuration can ultimately increase the speed of your site. It will automatically perform faster in serving end user’s request and also can speed your database queries and application processing. You can add a load balancer to improve the performance of your site. Load balancer balances the requests received by end user when actual server is running out of memory. Your load balancer server will just perform like your actual server.

2. Implementing CDN
A CDN is a spread over network which delivers html pages and other web contents from the server to end user based on their geographical locations, the origin of the web page and content delivery server. Implementing a CDN is a really good idea to improvise the performance of your site. Fetching everything from your hosting server over the network can cause latency and will reduce the performance of your site. Thus implementing a CDN will really be helpful if the request is from where the CDN server is present and will not cause any network latency. Ultimately improving the performance of your site.

3. Caching
Caching is a process of temporarily storing the data you request in cache. For example, the files you automatically request by looking at a Web page are stored on your hard disk in a cache subdirectory under the directory for your browser. When you return to a page you’ve recently looked at, the browser can get those files from the cache rather than the original server, saving you time and saving the network the burden of additional traffic. Caching is a good technique to increase the performance of your site. It is mainly used for static content of your site. It will also reduce the network latency of your requests, thus increasing the speed and performance of the website.


Conclusion

TTFB is an important metric in measuring the performance of your site. Above mentioned measures to improve TTFB are fairly simple to implement. A TTFB time of 500 ms or less is recommended.


Written by Rohit Sevaramani, Tech Lead (MCP) at Eternus Solutions


4 Comments

  • sbobet128 says:

    Good post. I learn something new and challenging on sites I stumbleupon everyday.
    It’s always exciting to read through content from other
    writers and use something from other web sites.

    Also visit my web site :: sbobet128

  • 青森県 says:

    Simply wish to say your article is as surprising. The clearness in your
    publish is simply spectacular and i could suppose you
    are an expert in this subject. Well along with
    your permission let me to clutch your feed to
    stay up to date with forthcoming post. Thank you 1,000,000 and please carry
    on the enjoyable work.

  • products_submenu says:

    Great post.

  • thanksgiving garden flag says:

    Great post however I was wondering if you could write a litte
    more on this topic? I’d be very grateful if you could elaborate a little bit more.
    Bless you!

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    9 − 5 =

    Share This Blog

    Blog Archives

    Subscribe to our Newsletter