kubeless/functions/benchmark.sh

46 lines
1.3 KiB
Bash
Raw Normal View History

2019-04-02 22:18:13 +02:00
#!/bin/bash
2019-04-02 23:18:58 +02:00
functions=(hello matrix)
2019-04-02 22:18:13 +02:00
connections=(2 5 10 20 21 50 100 200 400 500 1000)
2019-04-02 22:46:20 +02:00
kuberhost="node1:32764"
2019-04-02 23:01:26 +02:00
WRK_INSTALLED=$(which wrk)
2019-04-02 23:11:40 +02:00
if [ "$WRK_INSTALLED" = "" ]
2019-04-02 23:01:26 +02:00
then
2019-04-02 23:04:16 +02:00
sudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
cd wrk
make
2019-04-02 23:06:01 +02:00
cp wrk /usr/local/bin
2019-04-02 23:01:26 +02:00
fi
HEY_INSTALLED=$(which hey)
2019-04-02 23:11:40 +02:00
if [ "$HEY_INSTALLED" = "" ]
2019-04-02 23:01:26 +02:00
then
apt update
2019-04-02 23:04:16 +02:00
apt install -y golang
go get -u github.com/rakyll/hey
2019-04-02 23:08:21 +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
for function in "${functions[@]}"
do
echo -e "Benchmarking $function\n"
2019-04-02 23:15:53 +02:00
echo -e "Output of $function is:\n"
2019-04-02 23:17:39 +02:00
curl --header "Host: $function.kubeless" --header "Content-Type:application/json" http://$kuberhost/$function
2019-04-02 23:19:46 +02:00
echo -e "\n"
2019-04-02 22:18:13 +02:00
for connection in "${connections[@]}"
do
2019-04-02 23:12:15 +02:00
if [[ $connection -lt 21 ]]
2019-04-02 22:18:13 +02:00
then
threads=$(($connection-1))
else
threads=20
fi
echo -e "Threads: $threads Connections $connection\n"
2019-04-02 23:17:39 +02:00
wrk -t$threads -d1m -c$connection -H"Host: $function.kubeless" -H"Content-Type:application/json" --latency http://$kuberhost/$function > ./$function.$connection.txt 2>&1
2019-04-02 22:42:30 +02:00
hey -n 10000 -c $connection -o csv -m GET -host "$function.kubeless" -T "application/json" http://$kuberhost/$function > $function.$connection.csv
2019-04-02 22:18:13 +02:00
done
2019-04-02 22:42:30 +02:00
done