Advance

How to test website loading speed in Linux

How to test website loading speed in Linux

A Linux system administrator needs to know some Linux tricks. In this article, you are going to learn how to test website loading speed in Linux. Need for speed is not just a game, it is really important and serious for either users and server administrators.

 

How to test website loading speed in Linux

In the following, we will show you how to how to test a website response time from the Linux command line. you will see how to check the time in seconds, it takes:

1- To perform name resolution.

2- For TCP connection to the server.

3- For the file transfer to begin.

4- For the first byte to be transferred.

5- For the complete operation.

Also, for HTTPS-enabled sites, you would verify how to test the time, in seconds, it takes:

  • for a redirect
  • SSL connection/handshake to the server (to be completed)
Recommended Article: How to install Nextcloud in Ubuntu

Buy Linux Virtual Private Server

 

Of course, you know about the cURL, yes, the powerful command-line tool to transfer data from or to a server that uses the FILE, FTP, FTPS, HTTP, HTTPS, and many other protocols. But we will learn you one of the lesser-known functionalities.

After a completed operation, you can use the useful option of cURL, -w, to print information on stdout.  It means that you may use some of its time-related variables to test the different response times listed above, of a website. 

$ curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null http://www.google.com

You may see the variables, that we review their formats:

time_namelookup – time, in seconds, it took from the start until the name resolving was completed.

time_connect – time, in seconds, it took from the start until the TCP connection to the remote host (or proxy) was completed.

time_pretransfer – time, in seconds, it took from the start until the file transfer was just about to begin.

time_starttransfer – time, in seconds, it took from the start until the first byte was just about to be transferred.

time_total – total time, in seconds, that the full operation lasted (millisecond resolution).

Also, you can use use the syntax below, if the format was too long.

$ curl -s -w "@format.txt" -o /dev/null https://www.google.com

And in the above command, the flag:

  • -s – tells curl to work silently.
  • -w – print the information on stdout.
  • -o – used to redirect the output (here we discard the output by redirecting it to /dev/null).

Run the following command for HTTPS sites.

$ curl -s -w 'Testing Website Response Time for :%{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nAppCon Time:\t\t%{time_appconnect}\nRedirect Time:\t\t%{time_redirect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null https://www.google.com

And again, in the above  format, the new time variables are:

time_appconnect – time, in seconds, it took from the start until the SSL connect/handshake to the remote host was completed.

time_redirect – time, in seconds, it took for all redirection steps including name lookup, connect, pretransfer, and transfer before the final transaction was started; it computes the full execution time for multiple redirections.

Note:

1- As the response time values would always change, try to collect several values and get average speed, because you run different tests.

2- Due to the results of the commands above, you can see that accessing a website over HTTP is much faster than over HTTPS.

You are recommended to visit the cURL man page to get more information.

man curl

conclusion

in case you did not receive a suitable result, you need to consider some adjustments to make on your server or within the code.

 

you may be more informed if you follow Linux tricks.

Dear user, we hope you would enjoy this tutorial how to test website loading speed in Linux, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+18054214518

7 days a week, 24 hours a day