Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding automated localhost benchmark for OSX #1

Merged
merged 3 commits into from Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -26,7 +26,7 @@ java -jar target/zuul-0.0.1-SNAPSHOT.jar

## Terminal 3 (gateway)
```bash
cd zuul
cd gateway
./mvnw clean package
java -jar target/gateway-0.0.1-SNAPSHOT.jar
```
Expand Down
212 changes: 212 additions & 0 deletions benchmark.sh
@@ -0,0 +1,212 @@
#!/bin/bash
# A Bash script to execute a Benchmark about implementation of Gateway pattern for Spring Cloud

echo "Gateway Benchmark Script"

OSX="OSX"
WIN="WIN"
LINUX="LINUX"
UNKNOWN="UNKNOWN"
PLATFORM=$UNKNOWN

function detectOS() {

if [[ "$OSTYPE" == "linux-gnu" ]]; then
PLATFORM=$LINUX
elif [[ "$OSTYPE" == "darwin"* ]]; then
PLATFORM=$OSX
elif [[ "$OSTYPE" == "cygwin" ]]; then
PLATFORM=$WIN
elif [[ "$OSTYPE" == "msys" ]]; then
PLATFORM=$WIN
elif [[ "$OSTYPE" == "win32" ]]; then
PLATFORM=$WIN
else
PLATFORM=$UNKNOWN
fi

echo "Platform detected: $PLATFORM"
echo

if [ "$PLATFORM" == "$UNKNOWN" ]; then
echo "Sorry, this platform is not recognized by this Script."
echo
echo "Open a issue if the problem continues:"
echo "https://github.com/spencergibb/spring-cloud-gateway-bench/issues"
echo
exit 1
fi

}

function detectGo() {

if type -p go; then
echo "Found Go executable in PATH"
else
echo "Not found Go installed"
exit 1
fi

}

function detectJava() {

if type -p java; then
echo "Found Java executable in PATH"
else
echo "Not found Java installed"
exit 1
fi

}

function detectMaven() {

if type -p mvn; then
echo "Found Maven executable in PATH"
else
echo "Not found Java installed"
exit 1
fi

}

function detectWrk() {

if type -p wrk; then
echo "Found wrk executable in PATH"
else
echo "Not found wrk installed"
exit 1
fi

}

function setup(){

detectOS

detectGo
detectJava
detectMaven

detectWrk

mkdir -p reports
rm ./reports/*.txt
}

setup

#Launching the different services

function runStatic() {

cd static
if [ "$PLATFORM" == "$OSX" ]; then
GOOS=darwin GOARCH=amd64 go build -o webserver.darwin-amd64 webserver.go
./webserver.darwin-amd64
elif [ "$PLATFORM" == "$LINUX" ]; then
echo "Googling"
exit 1
elif [ "$PLATFORM" == "$WIN" ]; then
echo "Googling"
exit 1
else
echo "Googling"
exit 1
fi

}

function runZuul() {

echo "Running Gateway Zuul"

cd zuul
./mvnw clean package
java -jar target/zuul-0.0.1-SNAPSHOT.jar
}

function runGateway() {

echo "Running Spring Gateway"

cd gateway
./mvnw clean package
java -jar target/gateway-0.0.1-SNAPSHOT.jar
}

function runLinkerd() {

echo "Running Gateway Linkerd"

cd linkerd
java -jar linkerd-1.3.4.jar linkerd.yaml
}

# trap ctrl-c and call ctrl_c()
trap ctrl_c INT

function ctrl_c() {
echo "** Trapped CTRL-C"
kill $(ps aux | grep './webserver.darwin-amd64' | awk '{print $2}')
pkill java
exit 1
}

#Run Static web server
runStatic &

echo "Wait 10"
sleep 10

function runGateways() {

echo "Run Gateways"
runZuul &
runGateway &
runLinkerd &

}

runGateways

#Execute performance tests

function warnup() {

echo "JVM Warnup"

for run in {1..10}
do
wrk -t 10 -c 200 -d 30s http://localhost:8082/hello.txt >> ./reports/gateway.txt
done

for run in {1..10}
do
wrk -H "Host: web" -t 10 -c 200 -d 30s http://localhost:4140/hello.txt >> ./reports/linkerd.txt
done

for run in {1..10}
do
wrk -t 10 -c 200 -d 30s http://localhost:8081/hello.txt >> ./reports/zuul.txt
done
}

function runPerformanceTests() {

echo "Static results"
wrk -t 10 -c 200 -d 30s http://localhost:8000/hello.txt > ./reports/static.txt

echo "Wait 60 seconds"
sleep 60

warnup
}

runPerformanceTests

ctrl_c
echo "Script Finished"
95 changes: 95 additions & 0 deletions reports/gateway.txt
@@ -0,0 +1,95 @@
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 94.46ms 114.17ms 1.98s 94.42%
Req/Sec 245.75 79.24 590.00 71.43%
69430 requests in 30.08s, 9.80MB read
Socket errors: connect 0, read 151, write 5, timeout 106
Requests/sec: 2308.38
Transfer/sec: 333.64KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 70.10ms 65.45ms 735.14ms 76.18%
Req/Sec 331.12 121.85 1.14k 68.67%
98309 requests in 30.10s, 13.88MB read
Socket errors: connect 0, read 182, write 0, timeout 0
Non-2xx or 3xx responses: 2
Requests/sec: 3266.24
Transfer/sec: 472.10KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 69.66ms 63.80ms 928.06ms 75.01%
Req/Sec 329.90 129.90 830.00 66.60%
98391 requests in 30.04s, 13.89MB read
Socket errors: connect 0, read 182, write 0, timeout 0
Non-2xx or 3xx responses: 1
Requests/sec: 3275.73
Transfer/sec: 473.45KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 64.90ms 63.06ms 766.89ms 83.93%
Req/Sec 362.26 152.24 2.09k 69.65%
106891 requests in 30.10s, 15.09MB read
Socket errors: connect 0, read 193, write 0, timeout 0
Requests/sec: 3551.38
Transfer/sec: 513.30KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 56.49ms 48.79ms 453.57ms 73.11%
Req/Sec 401.71 134.95 1.05k 67.42%
120143 requests in 30.09s, 16.96MB read
Socket errors: connect 0, read 167, write 0, timeout 0
Non-2xx or 3xx responses: 1
Requests/sec: 3992.13
Transfer/sec: 577.01KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 63.15ms 58.71ms 604.65ms 79.08%
Req/Sec 374.53 144.79 797.00 65.98%
111533 requests in 30.03s, 15.74MB read
Socket errors: connect 0, read 160, write 0, timeout 0
Non-2xx or 3xx responses: 1
Requests/sec: 3714.10
Transfer/sec: 536.81KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 56.20ms 57.27ms 849.91ms 88.56%
Req/Sec 415.06 132.94 800.00 68.49%
123398 requests in 30.10s, 17.42MB read
Socket errors: connect 0, read 183, write 0, timeout 0
Non-2xx or 3xx responses: 1
Requests/sec: 4099.69
Transfer/sec: 592.55KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 54.72ms 55.47ms 739.17ms 89.06%
Req/Sec 421.86 127.47 0.89k 69.20%
124535 requests in 30.10s, 17.58MB read
Socket errors: connect 0, read 187, write 0, timeout 0
Requests/sec: 4137.99
Transfer/sec: 598.08KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 63.31ms 57.64ms 599.52ms 75.25%
Req/Sec 367.45 141.81 1.32k 67.41%
109399 requests in 30.10s, 15.44MB read
Socket errors: connect 0, read 165, write 0, timeout 0
Requests/sec: 3634.62
Transfer/sec: 525.32KB
Running 30s test @ http://localhost:8082/hello.txt
10 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 55.26ms 49.36ms 552.37ms 77.35%
Req/Sec 417.97 123.65 0.88k 68.51%
123747 requests in 30.09s, 17.47MB read
Socket errors: connect 0, read 92, write 14, timeout 0
Requests/sec: 4112.18
Transfer/sec: 594.35KB