I've noticed some intermittent performance issues with certain web pages that I've been working. So, I've decided to debug this further and run it by simulating the load. I've ended up writing a shell script using the cURL command to simulate the load and find out the network statistics.

Here is the shell script and I've named this as performance.sh (remember the file name here as this would be used while running the test)

#!/bin/sh
if [ -z "$@" ]; then
    echo >&2 "You must supply the URL!"
    exit 1
fi
a=0
while [ "$a" -lt 15 ]    # this is loop1
do
	#echo $a
	a=`expr $a + 1`
	curl -o /dev/null -s -L -H "Cache-Control: no-cache" -w "DNS lookup: %{time_namelookup} | TLS handshake: %{time_appconnect} | TTFB including connection: %{time_starttransfer} | Time Total: %{time_total} | Size: %{size_download}\n" $1
done

We should provide the execute permission to the file after saving the above script. This will allow the file to be executed. By default, execution is disabled and we should enable explicitly using the chmod command as below.

shell-prompt:~$ chmod +x performance.sh

Execute the script just simply passing the URL as the parameter

shell-prompt:~$  ./performance.sh https://www.santhoshreddymandadi.com
DNS lookup: 0.038311 | TLS handshake: 0.453631 | TTFB including connection: 0.713298 | Time Total: 0.771366 | Size: 12465
DNS lookup: 0.001910 | TLS handshake: 0.327375 | TTFB including connection: 0.602292 | Time Total: 0.653541 | Size: 12465
DNS lookup: 0.001930 | TLS handshake: 0.332000 | TTFB including connection: 0.590837 | Time Total: 0.691973 | Size: 12465
DNS lookup: 0.001624 | TLS handshake: 0.349153 | TTFB including connection: 0.590225 | Time Total: 0.691531 | Size: 12465
DNS lookup: 0.001757 | TLS handshake: 0.332383 | TTFB including connection: 0.565658 | Time Total: 0.658696 | Size: 12465
DNS lookup: 0.001664 | TLS handshake: 0.334417 | TTFB including connection: 0.587550 | Time Total: 0.707262 | Size: 12465
DNS lookup: 0.007334 | TLS handshake: 3.472371 | TTFB including connection: 3.926466 | Time Total: 4.088001 | Size: 12465
DNS lookup: 0.010128 | TLS handshake: 0.539904 | TTFB including connection: 0.794837 | Time Total: 0.900503 | Size: 12465
DNS lookup: 0.007270 | TLS handshake: 3.472685 | TTFB including connection: 3.895164 | Time Total: 3.899254 | Size: 12465
DNS lookup: 0.001782 | TLS handshake: 0.409440 | TTFB including connection: 1.162279 | Time Total: 3.652237 | Size: 12465
DNS lookup: 0.007593 | TLS handshake: 0.442667 | TTFB including connection: 0.806757 | Time Total: 0.909298 | Size: 12465
DNS lookup: 0.001726 | TLS handshake: 0.332043 | TTFB including connection: 0.802953 | Time Total: 0.913154 | Size: 12465
DNS lookup: 0.001894 | TLS handshake: 0.433200 | TTFB including connection: 0.679752 | Time Total: 0.978791 | Size: 12465
DNS lookup: 0.001703 | TLS handshake: 0.395439 | TTFB including connection: 0.631281 | Time Total: 0.960010 | Size: 12465
DNS lookup: 0.001838 | TLS handshake: 1.287128 | TTFB including connection: 1.793940 | Time Total: 2.008809 | Size: 12465
shell-prompt:~$