2019-10-02 18:27:25 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#Configuration variables
|
2019-10-14 21:25:37 +02:00
|
|
|
functions=(isprime-kubeless-go-sc)
|
2019-10-20 21:53:43 +02:00
|
|
|
connections=(45)
|
|
|
|
times=(30s)
|
2019-10-14 21:25:37 +02:00
|
|
|
kuberhost="node1:31299"
|
2019-10-02 18:27:25 +02:00
|
|
|
maxthreads=40
|
2019-10-29 12:52:55 +01:00
|
|
|
kubeless=true
|
|
|
|
rps=500
|
2019-10-20 21:53:43 +02:00
|
|
|
#Climb mode configuration
|
2019-10-29 12:52:55 +01:00
|
|
|
climb_max=10
|
|
|
|
climb=1
|
2019-10-02 18:27:25 +02:00
|
|
|
|
|
|
|
HEY_INSTALLED=$(command -v hey)
|
2019-10-29 13:15:04 +01:00
|
|
|
if [[ $HEY_INSTALLED == "" ]]; then
|
|
|
|
apt update
|
|
|
|
apt install -y golang
|
|
|
|
go get -u github.com/rakyll/hey
|
|
|
|
cp "$HOME"/go/bin/hey /usr/local/bin
|
2019-10-02 18:27:25 +02:00
|
|
|
fi
|
|
|
|
|
2019-10-29 12:21:03 +01:00
|
|
|
LOADTEST_INSTALLED=$(command -v loadtest)
|
2019-10-29 13:15:04 +01:00
|
|
|
if [[ LOADTEST_INSTALLED == "" ]]; then
|
|
|
|
apt update
|
|
|
|
apt install -y nodejs npm
|
|
|
|
npm i -g loadtest
|
2019-10-29 12:21:03 +01:00
|
|
|
fi
|
|
|
|
|
2019-10-02 18:27:25 +02:00
|
|
|
echo -e "Benchmarking functions\n"
|
2019-10-29 13:15:04 +01:00
|
|
|
for function in "${functions[@]}"; do
|
2019-10-02 18:27:25 +02:00
|
|
|
function_friendly=$(echo $function | cut - -d'-' -f1)
|
|
|
|
echo -e "Benchmarking $function\n"
|
|
|
|
echo -e "Output of $function is:\n"
|
|
|
|
perl -pi -e 'chomp if eof' "$function_friendly".body
|
2019-10-29 13:15:04 +01:00
|
|
|
if $kubeless; then
|
2019-10-20 22:20:05 +02:00
|
|
|
curl --data-binary @"$function_friendly".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
|
|
|
|
else
|
|
|
|
curl --header "Host: $function.default.example.com" http://$kuberhost/
|
|
|
|
fi
|
2019-10-02 18:27:25 +02:00
|
|
|
echo -e "\n"
|
2019-10-29 13:15:04 +01:00
|
|
|
for connection in "${connections[@]}"; do
|
|
|
|
if [[ $connection -lt $((maxthreads + 1)) ]]; then
|
|
|
|
threads=$((connection - 1))
|
|
|
|
else
|
|
|
|
threads=$maxthreads
|
|
|
|
fi
|
|
|
|
echo -e "Threads: $threads Connections $connection\n"
|
|
|
|
for time in "${times[@]}"; do
|
|
|
|
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
|
|
|
|
echo -e "Time: $time\n"
|
|
|
|
if [[ $* == *"--fire"* ]]; then
|
2019-10-29 13:18:40 +01:00
|
|
|
echo -e "summary $datetime\n"
|
2019-10-29 13:15:04 +01:00
|
|
|
if $kubeless; then
|
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 13:35:44 +01:00
|
|
|
loadtest -k -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$connection"."$time"."$datetime".txt
|
2019-10-29 13:15:04 +01:00
|
|
|
else
|
|
|
|
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$connection"."$time"."$datetime".txt
|
|
|
|
fi
|
2019-10-02 18:27:25 +02:00
|
|
|
else
|
2019-10-29 13:15:04 +01:00
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 13:35:44 +01:00
|
|
|
loadtest -k -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".txt
|
2019-10-02 18:27:25 +02:00
|
|
|
else
|
2019-10-29 13:15:04 +01:00
|
|
|
hey -c "$connection" -q $rps -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".txt
|
2019-10-02 18:27:25 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2019-10-29 13:15:04 +01:00
|
|
|
if [[ $* == *"--csv"* ]]; then
|
|
|
|
echo -e "hey-csv $datetime\n"
|
|
|
|
if $kubeless; then
|
|
|
|
hey -c "$connection" -z "$time" -m POST -host "$function.kubeless" -D "$function_firendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$connection"."$time"."$datetime".csv
|
|
|
|
else
|
|
|
|
hey -c "$connection" -z "$time" -m POST -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$connection"."$time"."$datetime".csv
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $* == *"--for"* ]]; then
|
|
|
|
for num in 1 2 3 4 5 6 7 8 9 10; do
|
2019-10-29 13:18:40 +01:00
|
|
|
echo -e "for $num\n"
|
2019-10-29 13:15:04 +01:00
|
|
|
if $kubeless; then
|
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 13:35:44 +01:00
|
|
|
loadtest -k -H "Host: $function.kubeless" --rps $rps -c $connection -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$num".txt
|
2019-10-20 22:20:05 +02:00
|
|
|
else
|
2019-10-29 13:15:04 +01:00
|
|
|
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$num".csv
|
2019-10-20 22:20:05 +02:00
|
|
|
fi
|
2019-10-29 13:15:04 +01:00
|
|
|
else
|
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 13:35:44 +01:00
|
|
|
loadtest -k -H "Host: $function.default.example.com" --rps $rps -c $connection -t $time http://$kuberhost/ >./data/"$function"."$num".for.csv
|
2019-10-20 22:20:05 +02:00
|
|
|
else
|
2019-10-29 13:15:04 +01:00
|
|
|
hey -c "$connection" -q $rps -z "$time" -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$num".for.csv
|
2019-10-20 22:20:05 +02:00
|
|
|
fi
|
2019-10-02 18:27:25 +02:00
|
|
|
fi
|
2019-10-29 13:15:04 +01:00
|
|
|
done
|
|
|
|
fi
|
2019-10-02 18:27:25 +02:00
|
|
|
done
|
2019-10-29 13:15:04 +01:00
|
|
|
done
|
|
|
|
if [[ $* == *"--climb"* ]]; then
|
2019-10-29 12:52:55 +01:00
|
|
|
while [[ $climb -lt $climb_max ]]; do
|
2019-10-29 13:15:04 +01:00
|
|
|
climb_rps=$((rps * climb))
|
2019-10-29 14:24:37 +01:00
|
|
|
echo -e "Rps: $climb_rps"
|
2019-10-29 13:15:04 +01:00
|
|
|
if $kubeless; then
|
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 14:24:37 +01:00
|
|
|
loadtest -k -H "Host: $function.kubeless" --rps $climb_rps -c 1 -t $time -p "$function_firendly".body http://$kuberhost/"$function" >./data/"$function"."$climb_rps".climb.txt
|
2019-10-29 12:52:55 +01:00
|
|
|
else
|
2019-10-29 14:38:20 +01:00
|
|
|
hey -c $climb -q $rps -z $time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" >./data/"$function"."$climb_rps".climb.csv
|
2019-10-29 12:52:55 +01:00
|
|
|
fi
|
2019-10-29 13:15:04 +01:00
|
|
|
else
|
|
|
|
if [[ $* == *"--loadtest"* ]]; then
|
2019-10-29 14:24:37 +01:00
|
|
|
loadtest -k -H "Host: $function.default.example.com" --rps $climb_rps -c 1 -t $time http://$kuberhost/ >./data/"$function"."$climb_rps".climb.txt
|
2019-10-29 12:52:55 +01:00
|
|
|
else
|
2019-10-29 14:38:20 +01:00
|
|
|
hey -c $climb -q $rps -z $time -m POST -o csv -host "$function.default.example.com" http://$kuberhost/ >./data/"$function"."$climb_rps".climb.csv
|
2019-10-29 12:52:55 +01:00
|
|
|
fi
|
2019-10-29 13:15:04 +01:00
|
|
|
fi
|
|
|
|
climb=$((climb + 1))
|
2019-10-20 21:53:43 +02:00
|
|
|
done
|
|
|
|
fi
|
2019-10-20 23:49:19 +02:00
|
|
|
echo -e "Finished at $datetime"
|
2019-10-02 18:27:25 +02:00
|
|
|
done
|