kubeless/benchmark/benchmark.sh

116 lines
4.6 KiB
Bash
Raw Normal View History

2019-05-04 19:18:36 +02:00
#!/usr/bin/env bash
2019-04-26 16:39:50 +02:00
#Requirements:
#<function name without dashes>.wrk descriptor file for wrk
#<function name without dashes>.body (even if you don't need it)
2019-04-02 22:18:13 +02:00
2019-04-26 16:39:50 +02:00
#Configuration variables
2019-04-26 16:13:03 +02:00
functions=(isprime-scale isprime-scale-py isprime-scale-js hello-scale hello-scale-py hello-scale-js hello hello-js hello-py isprime isprime-js isprime-py)
2019-04-26 16:22:38 +02:00
connections=(1000)
2019-04-25 11:21:38 +02:00
times=(1m)
2019-04-25 10:51:04 +02:00
kuberhost="node1:30765"
2019-04-26 16:22:38 +02:00
maxthreads=40
2019-04-26 16:39:50 +02:00
#Wave mode configuration
2019-04-26 14:32:55 +02:00
wave_connection=40
2019-04-26 15:16:25 +02:00
wave_max_conn=160
2019-04-26 14:32:55 +02:00
wave_min_conn=40
2019-04-25 13:46:53 +02:00
wave_time="1m"
2019-04-26 15:16:25 +02:00
wave_loop_max=2
2019-04-25 13:46:53 +02:00
2019-04-26 14:32:55 +02:00
WRK_INSTALLED=$(command -v wrk)
2019-04-25 13:46:53 +02:00
if [[ $WRK_INSTALLED = "" ]]
2019-04-02 23:01:26 +02:00
then
2019-04-17 14:09:03 +02:00
apt update
apt install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
2019-04-26 14:32:55 +02:00
cd wrk || exit
2019-05-07 13:57:27 +02:00
cores=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
make -j $((cores + 1))
2019-04-17 14:09:03 +02:00
cp wrk /usr/local/bin
2019-04-02 23:01:26 +02:00
fi
2019-04-26 14:32:55 +02:00
HEY_INSTALLED=$(command -v hey)
2019-04-25 13:46:53 +02:00
if [[ $HEY_INSTALLED = "" ]]
2019-04-02 23:01:26 +02:00
then
2019-04-17 14:09:03 +02:00
apt update
apt install -y golang
go get -u github.com/rakyll/hey
2019-04-26 14:32:55 +02:00
cp "$HOME"/go/bin/hey /usr/local/bin
2019-04-02 23:01:26 +02:00
fi
2019-04-02 22:18:13 +02:00
2019-04-26 15:12:05 +02:00
echo -e "Benchmarking functions\n"
for function in "${functions[@]}"
do
2019-04-26 16:15:41 +02:00
function_friendly=$(echo $function | cut - -d'-' -f1)
2019-04-26 15:16:25 +02:00
echo -e "Benchmarking $function\n"
2019-04-26 16:17:04 +02:00
echo -e "Output of $function is:\n"
2019-04-26 16:19:20 +02:00
perl -pi -e 'chomp if eof' "$function_friendly".body
2019-04-26 16:17:33 +02:00
curl --data-binary @"$function_friendly".body --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/"$function"
2019-04-26 16:17:04 +02:00
echo -e "\n"
2019-04-26 15:12:05 +02:00
if [[ $* = *"--wave"* ]]
then
2019-04-26 16:39:50 +02:00
wave_loop=1
wave_dir_up=true
2019-04-26 15:16:25 +02:00
while [[ $wave_loop -lt $wave_loop_max ]]; do
2019-04-26 15:12:05 +02:00
now=$(date '+%Y-%m-%d-%H-%M')
2019-04-26 16:18:22 +02:00
echo -e "Connections: $wave_connection"
2019-04-26 15:12:05 +02:00
echo -e "Running"
2019-05-01 00:35:15 +02:00
hey -c $wave_connection -z $wave_time -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$wave_connection"."$now".wave.csv
2019-04-26 17:03:06 +02:00
if $wave_dir_up
2019-04-26 14:32:55 +02:00
then
2019-04-26 16:59:27 +02:00
if [[ $wave_connection -lt $wave_max_conn ]]
2019-04-26 15:12:05 +02:00
then
2019-04-26 16:52:16 +02:00
echo -e "Stepping up"
2019-04-26 17:02:02 +02:00
wave_connection=$((wave_connection * 5))
2019-04-26 15:12:05 +02:00
else
2019-04-26 16:52:16 +02:00
echo -e "Not stepping"
2019-04-26 15:12:05 +02:00
wave_dir_up=false
fi
2019-04-26 14:32:55 +02:00
else
2019-04-26 16:59:27 +02:00
if [[ $wave_connection -gt $wave_min_conn ]]
2019-04-26 15:12:05 +02:00
then
2019-04-26 16:52:16 +02:00
echo -e "Stepping down"
2019-04-26 17:02:02 +02:00
wave_connection=$((wave_connection / 5))
2019-04-26 15:12:05 +02:00
else
2019-04-26 16:52:16 +02:00
echo -e "Not stepping"
2019-04-26 14:32:55 +02:00
wave_dir_up=true
2019-04-26 15:16:25 +02:00
wave_loop=$((wave_loop + 1))
2019-04-26 15:12:05 +02:00
fi
2019-04-26 14:32:55 +02:00
fi
2019-04-26 15:12:05 +02:00
done
else
for connection in "${connections[@]}"
2019-04-17 14:09:03 +02:00
do
2019-04-26 15:12:05 +02:00
if [[ $connection -lt $((maxthreads + 1)) ]]
then
threads=$((connection-1))
else
threads=$maxthreads
fi
echo -e "Threads: $threads Connections $connection\n"
for time in "${times[@]}"
2019-04-26 16:13:03 +02:00
do
2019-04-26 15:12:05 +02:00
datetime=$(date '+%Y-%m-%d-%H-%M-%S')
echo -e "Time: $time\n"
2019-04-26 16:39:50 +02:00
if [[ $* = *"--wrk"* ]]
then
echo -e "wrk $datetime\n"
2019-05-01 00:35:15 +02:00
wrk -t$threads -c"$connection" -d"$time" -s"$function_friendly".wrk -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".wrk.txt 2>&1
2019-04-26 16:39:50 +02:00
fi
if [[ $* = *"--hey"* ]]
then
echo -e "hey-summary $datetime\n"
2019-05-01 00:35:15 +02:00
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".hey.txt
2019-04-26 16:39:50 +02:00
fi
if [[ $* = *"--csv"* ]]
then
echo -e "hey-csv $datetime\n"
2019-05-01 00:35:15 +02:00
hey -c "$connection" -z "$time" -m POST -o csv -host "$function.kubeless" -D "$function_friendly".body -T "application/json" http://$kuberhost/"$function" > ./data/"$function"."$connection"."$time"."$datetime".csv
2019-04-26 16:39:50 +02:00
fi
echo -e "Finished at $datetime"
2019-04-26 15:12:05 +02:00
done
2019-04-03 00:10:38 +02:00
done
2019-04-26 15:12:05 +02:00
fi
2019-04-03 00:10:38 +02:00
done
2019-05-02 13:32:48 +02:00
python3 ./data/process.py > ./data/processed.txt