This repository has been archived by the owner on Mar 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
5,023 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
test/.tmp | ||
test/fixtures | ||
*.nar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Benchmark | ||
|
||
Simple benchmark suite for `rocky` | ||
|
||
## Requirements | ||
|
||
- Go +1.3 | ||
- vegeta `go get github.com/tsenart/vegeta` | ||
|
||
## Run it! | ||
|
||
``` | ||
bash benchmark/run.sh | ||
``` | ||
|
||
Supported optional arguments: | ||
``` | ||
bash benchmark/run.sh [rocky url] [rate] [duration] | ||
``` | ||
|
||
Example: | ||
``` | ||
bash benchmark/run.sh http://rocky.server:8080 200 60s | ||
``` | ||
|
||
## Suite results | ||
|
||
Using a Macbook Pro i7 2.7 Ghz 16 GB OSX Yosemite and `[email protected]` | ||
|
||
##### Simple forward (200 req/sec) | ||
``` | ||
# Running benchmark suite: forward | ||
Requests [total] 1000 | ||
Duration [total, attack, wait] 9.994724089s, 9.991463892s, 3.260197ms | ||
Latencies [mean, 50, 95, 99, max] 3.696245ms, 3.39041ms, 7.345854ms, 41.871707ms, 41.871707ms | ||
Bytes In [total, mean] 12000, 12.00 | ||
Bytes Out [total, mean] 0, 0.00 | ||
Success [ratio] 100.00% | ||
Status Codes [code:count] 200:1000 | ||
``` | ||
|
||
##### Forward + replay to 2 backends (200 req/sec) | ||
``` | ||
# Running benchmark suite: replay | ||
Requests [total] 1000 | ||
Duration [total, attack, wait] 9.995610711s, 9.992172904s, 3.437807ms | ||
Latencies [mean, 50, 95, 99, max] 4.825458ms, 4.321398ms, 7.390831ms, 44.316375ms, 44.316375ms | ||
Bytes In [total, mean] 12000, 12.00 | ||
Bytes Out [total, mean] 0, 0.00 | ||
Success [ratio] 100.00% | ||
Status Codes [code:count] 200:1000 | ||
``` | ||
|
||
##### Forward with POST payload (~250KB) (50 req/sec) | ||
``` | ||
# Running benchmark suite: forward-payload | ||
Requests [total] 500 | ||
Duration [total, attack, wait] 1m0.401897863s, 9.984355502s, 50.417542361s | ||
Latencies [mean, 50, 95, 99, max] 125.460034ms, 4.99145ms, 10.086713ms, 1m0.001088277s, 1m0.001088277s | ||
Bytes In [total, mean] 6131, 12.26 | ||
Bytes Out [total, mean] 116857317, 233714.63 | ||
Success [ratio] 97.60% | ||
Status Codes [code:count] 200:486 502:6 | ||
Error Set: | ||
502 Bad Gateway | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
# | ||
# Simple benchmark test suite for rocky | ||
# | ||
# You must have vegeta installed: | ||
# go get github.com/tsenart/vegeta | ||
# | ||
|
||
# | ||
# Benchmark config | ||
# | ||
url="http://localhost:9000" # default rocky proxy URL | ||
rate=100 # concurrent requests per second | ||
duration=10s # benchmark duration in human friendly format | ||
|
||
# | ||
# Read from arguments | ||
# | ||
[ ! -z $1 ] && url=$1 | ||
[ ! -z $2 ] && rate=$2 | ||
[ ! -z $3 ] && duration=$3 | ||
|
||
# | ||
# Test variables | ||
# | ||
current=0 | ||
proxyPid=0 | ||
serverPid=0 | ||
|
||
if [ -z `which vegeta` ]; then | ||
echo "Error: vegeta binary not found. Run: go get github.com/tsenart/vegeta" | ||
exit 1 | ||
fi | ||
|
||
cd `dirname $0` | ||
|
||
targetServer() { | ||
node servers & > /dev/null | ||
serverPid=$! | ||
} | ||
|
||
proxyServer() { | ||
node suites/$1 & > /dev/null | ||
proxyPid=$! | ||
} | ||
|
||
before() { | ||
proxyServer $1 | ||
targetServer | ||
sleep 1 | ||
} | ||
|
||
after() { | ||
disown $serverPid | ||
disown $proxyPid | ||
kill -9 $serverPid | ||
kill -9 $proxyPid | ||
} | ||
|
||
getBenchmark() { | ||
echo "GET $url" \ | ||
| vegeta attack \ | ||
-duration=$duration \ | ||
-rate=$rate \ | ||
| vegeta report | ||
} | ||
|
||
postBenchmark() { | ||
echo "POST $url" \ | ||
| vegeta attack \ | ||
-duration=$duration \ | ||
-rate=50 \ | ||
-timeout=60s \ | ||
-body="../test/fixtures/data.json" \ | ||
| vegeta report | ||
} | ||
|
||
test() { | ||
before $1 | ||
|
||
echo "# Running benchmark suite: $1" | ||
$2 # run test function! | ||
echo | ||
|
||
after | ||
} | ||
|
||
# | ||
# Run suites | ||
# | ||
test "forward" getBenchmark | ||
test "replay" getBenchmark | ||
test "forward-payload" postBenchmark | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const http = require('http') | ||
|
||
http.createServer(function (req, res) { | ||
res.end('Hello world!') | ||
}).listen(9001) | ||
|
||
http.createServer(function (req, res) { | ||
res.end('Hello world!') | ||
}).listen(9002) | ||
|
||
http.createServer(function (req, res) { | ||
res.end('Hello world!') | ||
}).listen(9003) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const rocky = require('../..') | ||
const timeout = 60 * 1000 | ||
|
||
rocky({ timeout: timeout, proxyTimeout: timeout }) | ||
.forward('http://localhost:9001') | ||
.replay('http://localhost:9002') | ||
.listen(9000) | ||
.post('/*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const rocky = require('../..') | ||
|
||
rocky() | ||
.forward('http://localhost:9001') | ||
.listen(9000) | ||
.all('/*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const rocky = require('../..') | ||
|
||
rocky() | ||
.forward('http://localhost:9001') | ||
.replay('http://localhost:9002') | ||
.replay('http://localhost:9003') | ||
.listen(9000) | ||
.all('/*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.