Skip to content

Commit

Permalink
Refactor benchmark and timer scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyaonoe committed Dec 5, 2024
1 parent 2f7e0dc commit 497be0b
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 21 deletions.
17 changes: 6 additions & 11 deletions delay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,22 @@ kubectl apply -f ingressgateway-svc.yaml
```

# Measurements
```bash
cd script
go run timertt/main.go <options>
```

Please change --client-num from 1~64
### base
```bash
go run timertt/main.go --url http://service-istio.service-istio.svc.cluster.local:32001 --prefix base --env-id main --req-per-sec 1000 --duration 10 --client-num 1 --payload 1000
./benchmark.sh base <PREFIX> <CLIENT>
```
### base+proposed
### base+picop
```bash
go run timertt/main.go --url http://service-istio.service-istio.svc.cluster.local:31002 --prefix base+proposed --env-id main --req-per-sec 1000 --duration 10 --client-num 1 --payload 1000 --picop
./benchmark.sh base+picop <PREFIX> <CLIENT>
```
### base+gw+istio
```bash
go run timertt/main.go --url http://service-istio.service-istio.svc.cluster.local:30001 --prefix base+gw+istio --env-id main --req-per-sec 1000 --duration 10 --client-num 1 --payload 1000
./benchmark.sh base+gw+istio <PREFIX> <CLIENT>
```
### base+gw+proposed
### base+gw+picop
```bash
go run timertt/main.go --url http://proxy-both.service.svc.cluster.local:30002 --prefix base+gw+proposed --env-id main --req-per-sec 1000 --duration 10 --client-num 1 --payload 1000 --picop
./benchmark.sh base+gw+picop <PREFIX> <CLIENT>
```

# Outputs
Expand Down
58 changes: 58 additions & 0 deletions delay/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash -eux

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <type> <prefix> <client>"
exit 1
fi

PREFIX=$1
CLIENT=$2

# TYPE=base
# TYPE=base+picop
# TYPE=base+gw+istio
# TYPE=base+gw+picop

DURATION=10
RPS=1000

TIMESTAMP=$(date +%s)
NAME="data/$PREFIX/$TYPE/$CLIENT-$RPS-$DURATION/$TIMESTAMP"

if [ "$TYPE" = "base" ]; then
URL="http://service-istio.service-istio.svc.cluster.local:32001"
OPTION=""
elif [ "$TYPE" = "base+picop" ]; then
URL="http://service-istio.service-istio.svc.cluster.local:31002"
OPTION="--picop"
elif [ "$TYPE" = "base+gw+istio" ]; then
URL="http://service-istio.service-istio.svc.cluster.local:30001"
OPTION=""
elif [ "$TYPE" = "base+gw+picop" ]; then
URL="hhttp://proxy-both.service.svc.cluster.local:30002"
OPTION="--picop"
else
echo "Invalid type: $TYPE"
exit 1
fi

CMD="/usr/local/go/bin/go run timertt/main.go --url $URL --prefix $NAME --env-id main --req-per-sec $RPS --duration $DURATION --client-num $CLIENT --payload 1000 $OPTION"

echo "NAME: $NAME"
echo "CMD: $CMD"
echo "TIMESTAMP: $TIMESTAMP"

cleanup() {
echo "SIGINT received, cleaning up..."
ssh onoe-benchmark-1 "pkill -2 --echo 'go'"

kill $(jobs -p)
exit 1
}

trap 'cleanup' SIGINT

ssh onoe-benchmark-1 "cd benchmark/consumption && $CMD"

mkdir -p ./data/$PREFIX/$TYPE/$CLIENT-$RPS-$DURATION
scp onoe-benchmark-1:benchmark/consumption/$NAME.csv ./$NAME.csv
19 changes: 19 additions & 0 deletions delay/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -ux

cd kubernetes/manifests

kubectl delete -f namespace.yaml
kubectl apply -f namespace.yaml
kubectl apply -f proxy-http.yaml
kubectl apply -f proxy-both.yaml
./script/create-service.sh http main | kubectl -n service apply -f -
./script/create-service.sh http feature-1 | kubectl -n service apply -f -
./script/create-service.sh http main | kubectl -n service-istio apply -f -
./script/create-service.sh http feature-1 | kubectl -n service-istio apply -f -

cd ../../istio
kubectl delete -f namespace.yaml
kubectl apply -f namespace.yaml
kubectl apply -f gateway.yaml
kubectl apply -f vs.yaml
kubectl apply -f ingressgateway-svc.yaml
19 changes: 9 additions & 10 deletions delay/script/timertt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func main() {

flag.Parse()

now := time.Now().Local().Format(time.RFC3339)
reqTotal := *reqPerSec * *reqDuration

out := fmt.Sprintf("%s-rtt-%s-%t-%d-%d-%d-%d-%s.csv", *prefix, *envID, *picop, *reqPerSec, *reqDuration, *clientNum, *payload, now)
out := fmt.Sprintf("%s.csv", *prefix)
fmt.Printf("Output file: %s\n", out)

if _, err := os.Stat(out); err == nil {
Expand Down Expand Up @@ -68,7 +67,7 @@ func main() {

var wg sync.WaitGroup

interval := time.Duration(*clientNum) * time.Second / time.Duration(*reqPerSec)
interval := time.Second / time.Duration(*reqPerSec)
fmt.Printf("interval: %d", interval)

ticker := time.NewTicker(interval)
Expand All @@ -80,9 +79,9 @@ func main() {
i := 0
// after := time.After(time.Duration(*reqDuration) * time.Second)
for {
select {
case <-ticker.C:
for j := 0; j < *clientNum; j++ {
for j := 0; j < *clientNum; j++ {
select {
case <-ticker.C:
if i >= reqTotal {
goto WAIT
}
Expand Down Expand Up @@ -123,11 +122,11 @@ func main() {
fmt.Printf("End: %d\n", count)
}(i)
i++
case <-stopper:
goto END
// case <-after:
// goto END
}
case <-stopper:
goto END
// case <-after:
// goto END
}
}
WAIT:
Expand Down

0 comments on commit 497be0b

Please sign in to comment.