Skip to content

Instantly share code, notes, and snippets.

@porjo
Last active November 13, 2018 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porjo/655929016030c2458d86d00013b8ee15 to your computer and use it in GitHub Desktop.
Save porjo/655929016030c2458d86d00013b8ee15 to your computer and use it in GitHub Desktop.
Compare AWS ELB response times
#!/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