Table of contents of the article:
In the world of web hosting, we often talk about TTFB, an acronym for Time To First Byte. It is a fundamental parameter to measure the speed with which a web server responds to a request. TTFB is the time between a client sending an HTTP request and the server receiving the first byte of data.
However, another parameter deserves our attention, even if it is often overlooked: the TTLB, or Time To Last Byte. This metric, while lesser known, plays an equally critical role in determining a website's overall performance. Although it is not talked about much, its importance is undeniable.
What is TTLB (Time To Last Byte)?
The TTLB, as the name suggests, represents the time it takes for a server to send the last response byte to a client request. In other words, it is the total time that a client must wait to receive the entire response from the server. This metric is especially useful for measuring how fast data is downloaded from the server.
The TTLB includes the content transmission time, i.e. the time required to transfer all data from the source to the recipient, as well as the time taken by the server to process the request. This parameter is important for understanding how quickly a user can view the entire web page or download a file from the server.
The relationship between TTFB and TTLB
While the TTFB indicates how quickly a server can start responding to a request, the TTLB indicates how long it takes to complete the response. A lower TTFB indicates that the server is able to start responding quickly, which is critical to user experience, especially for dynamic web pages.
However, a low TTFB does not necessarily guarantee a low TTLB. If the server takes a long time to send the entire response, the user may have to wait a significant amount of time to view the entire page or to download a file, even if the response started quickly. This underscores the importance of monitoring both TTFB and TTLB.
How to optimize the TTLB.
Slow server response can seriously affect performance. If the browser waits more than 600ms for a response, that's an indication that something isn't working as it should. Excessive delay in server response can cause long page load times, a problem that web users do not tolerate.
When users visit a URL through their browser, it sends a network request to get the desired content. The server receives this request and delivers the page content. It can take considerable server effort to generate a page with all the dynamic content that users want to see. For example, if a user is checking his order history, the server must collect this information from the database and then integrate it into the page.
Improving server performance to reduce the waiting time while loading pages is a crucial step. The first step in optimizing server response time is to identify the main operations that the server must perform to generate the page content and then measure how long it takes for each of them. Once the most time-consuming activities have been identified, solutions can be sought to speed them up.
There are numerous reasons that can cause a slow server to respond, and consequently there are multiple ways to make improvements:
- Enable GZIP compression for connections.
- Improve server application logic to generate pages faster. Each technology stack and web server has its own specific recommendations for optimizing performance; for PHP, for example, OPCACHE is available.
- Review and optimize how your server interacts with databases, or consider upgrading to higher-performance database systems.
- Upgrade your server hardware by increasing memory or CPU.
More briefly, our Hosting solutions are already optimized to solve all TTFB and TTLB problems.
How to measure TTLB using Linux commands
There are several ways to measure TTLB, and one of the most common methods makes use of the command curl
on a Linux system. Here is an example of how this can be done:
time curl -so /dev/null http://example.com
In this command, time
is a Linux command that measures the execution time of another command. curl
is a command used to download or send data through various network protocols. The option -s
causes that curl
works silently, without showing the progress bar, while the option -o
redirect the output to a file, or in this case, a /dev/null
, so that you don't see the downloaded data in the terminal.
The command will return something like:
real 0m0.412s user 0m0.006s sys 0m0.005s
The 'real' time is the TTLB we are looking for. Indicates the total time elapsed from the moment the command was sent until the moment the last byte was received.
Conclusion
In conclusion, TTLB is an extremely useful metric for measuring server performance. While not discussed as much as TTFB, it is critical to understanding how long a user will have to wait to receive the entire response from the server. Monitoring TTLB in conjunction with TTFB can provide a more complete picture of your server's performance and allow you to make targeted optimizations to improve the end user experience.