How to Check TTFB (Time To First Byte) using CURL

How to Check TTFB (Time To First Byte) using CURL

Now, Google use website speed as SEO ranking factor. Google tells that users won’t wait slow site.

Time to first byte (TTBF) is one of the many reasons why a website is fast or slow.

Time to first byte (TTFB) is a measurement used as an indication of the responsiveness of a webserver or other network resource.

TTFB measures the duration from the user or client making an HTTP request to the first byte of the page being received by the client’s browser.

This time is made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page.

Although sometimes misunderstood as a post-DNS calculation, the original calculation of TTFB in networking always includes network latency in measuring the time it takes for a resource to begin loading.

Often, a smaller (faster) TTFB size is seen as a benchmark of a well-configured server application.

For example, a lower time to first byte could point to fewer dynamic calculations being performed by the webserver, although this is often due to caching at either the DNS, server, or application level.

More commonly, a very low TTFB is observed with statically served web pages, while larger TTFB is often seen with larger, dynamic data requests being pulled from a database.

If you want to know more about TTBF, see on Wikipedia and check on Chrome Devtools by Google Team.

How to Check TTFB (Time To First Byte) using CURL

You can check Time To First Byte with curl. The command is like below:

# curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" "https://serverdiary.com"

Sample output:

# curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" "https://serverdiary.com"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82863    0 82863    0     0   435k      0 --:--:-- --:--:-- --:--:--  437k
Connect: 0.061 TTFB: 0.185 Total time: 0.186
Time To First Byte (TTBF)
Time To First Byte (TTBF) from Germany (Europe)

We can see that’s is very great result, TTBF is 185 ms. Serverdiary.com’s servers is in Germany and test from Germany.

Let’s see result from server in Singapore (Digital Ocean).

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" "https://serverdiary.com"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82863    0 82863    0     0  66246      0 --:--:--  0:00:01 --:--:-- 66237
Connect: 0.243 TTFB: 1.071 Total time: 1.251
Time To First Byte (TTBF) from Singapore (Asia)

Not good enough, more than 1 second.

Let’s see result from Indonesia, using consumer connection.

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" "https://serverdiary.com"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82863    0 82863    0     0  24341      0 --:--:--  0:00:03 --:--:-- 24342
Connect: 0.218054 TTFB: 2.642163 Total time: 3.404156

Bad results, TTBF more than 2 seconds. Because TTBF include DNS resolve, let’s check second request.

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" "https://serverdiary.com"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82863    0 82863    0     0  18930      0 --:--:--  0:00:04 --:--:-- 18931
Connect: 0.210015 TTFB: 1.422349 Total time: 4.377296

Second request got better results, because it’s cut DNS resolve.

Time To First Byte (TTBF) from Indonesia (Asia)

You can check Time To First Byte (TTBF) online on https://snapitweb.com/ttbf-checker

Online Time To First Byte (TTBF) checker
Online Time To First Byte (TTBF) checker

Leave a Reply

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