Last active
November 13, 2018 00:54
-
-
Save porjo/655929016030c2458d86d00013b8ee15 to your computer and use it in GitHub Desktop.
Compare AWS ELB response times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# compare AWS ELB: CLB (classic) and ALB (application) response times | |
# all output times are in seconds | |
CLB_URL="https://clb.example.com" | |
ALB_URL="https://alb.example.com" | |
clb_wins=0 | |
alb_wins=0 | |
echo -e "CLB Time\tALB Time\tDifference\tWinner\tCLB Wins\tALB Wins" | |
while true; do | |
start=`date +%s.%N` | |
curl $ALB_URL &> /dev/null | |
end=`date +%s.%N` | |
alb_walltime=$(echo "$end-$start" | bc) | |
start=`date +%s.%N` | |
curl $CLB_URL &> /dev/null | |
end=`date +%s.%N` | |
clb_walltime=$(echo "$end-$start" | bc) | |
if [ $(echo "define abs(x) {if (x<0) {return -x}; return x;}; abs($clb_walltime-$alb_walltime) < 0.001" | bc) -eq 1 ]; then | |
winner="tie" | |
else | |
if [ $(echo "$clb_walltime>$alb_walltime" | bc) -eq 1 ] ; then | |
winner="alb" | |
alb_wins=$((alb_wins + 1)) | |
else | |
winner="clb" | |
clb_wins=$((clb_wins + 1)) | |
fi | |
fi | |
echo -e "$clb_walltime\t$alb_walltime\t"$(echo "$clb_walltime-$alb_walltime" | bc)"\t$winner\t$clb_wins\t$alb_wins" | |
sleep 0.1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment