Skip to content

Commit

Permalink
Refactor scripts and remove unused YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyaonoe committed Dec 5, 2024
1 parent 03820ba commit e172e1a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 171 deletions.
9 changes: 2 additions & 7 deletions consumption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ You can measure proxy resource consumption (vCPU and memory).
[Common Steps](../docs/common.md)

```bash
cd kubernetes/manifests
kubectl apply -f namespace.yaml
kubectl apply -f proxy-http.yaml
kubectl apply -f service.yaml
./restart.sh
```

# Measurements
Please change --req-per-sec from 1~10000
```bash
cd script
go run --url http://<Kubernetes Cluster URL>:32001 --env-id main --req-per-sec 1000 --duration 90 --client-num 1 --payload 1000 --picop
./benchmark.sh <type> <prefix> <rps>
```

# Outputs
Expand Down
66 changes: 45 additions & 21 deletions consumption/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,47 +1,71 @@
#!/bin/bash -eux

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

PREFIX=$1
TYPE=$1
PREFIX=$2
RPS=#3

URL="http://10.229.71.125:32001"
ENVID=main
DURATION=300
CONN=1
RPS=1000
PAYLOAD=1000
# TYPE=base
# TYPE=base+picop
# TYPE=base+gw+istio
# TYPE=base+gw+picop

INTERVAL=10
DURATION=300
CLIENT=1

NAME="$PREFIX/$ENVID-$CONN-$RPS-$DURATION-$PAYLOAD-$INTERVAL"
TIMESTAMP=$(date +%s)
NAME="$PREFIX/$TYPE/$CLIENT-$RPS-$DURATION/$TIMESTAMP"

CMD="/usr/local/go/bin/go run ./script/main.go --url $URL --env-id $ENVID --req-per-sec $RPS --duration $DURATION --client-num $CONN --payload $PAYLOAD --picop"
if [ "$TYPE" = "base" ]; then
echo "Invalid type: $TYPE"
exit 1
# URL="http://service-istio.service-istio.svc.cluster.local:32001"
# OPTION=""
# NS="service"
elif [ "$TYPE" = "base+picop" ]; then
echo "Invalid type: $TYPE"
exit 1
# URL="http://service-istio.service-istio.svc.cluster.local:31002"
# OPTION="--picop"
# NS="service"
elif [ "$TYPE" = "base+gw+istio" ]; then
URL="http://service-istio.service-istio.svc.cluster.local:30001"
OPTION=""
NS="service-istio"
elif [ "$TYPE" = "base+gw+picop" ]; then
URL="http://proxy-both.service.svc.cluster.local:30002"
OPTION="--picop"
NS="service"
else
echo "Invalid type: $TYPE"
exit 1
fi

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

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

kill $(jobs -p)
exit 1
}

trap 'cleanup' SIGINT

ssh onoe-benchmark "cd benchmark/consumption && ./exec-cmd.sh '$CMD' ./data/cmd/$NAME $TIMESTAMP" &
ssh onoe-benchmark-1 "cd benchmark/delay && $CMD" &

go run ./collect/main.go -name $NAME -timestamp $TIMESTAMP -dir ./data/input -interval $INTERVAL -duration $DURATION kubectl top pod -n service-proxy &
go run ./collect/main.go -name ./data/input/$NAME -timestamp $TIMESTAMP -interval $INTERVAL -duration $DURATION kubectl top pod -n $NS --containers &

wait

mkdir -p ./data/cmd/$NAME
scp onoe-benchmark:benchmark/consumption/data/cmd/$NAME/$TIMESTAMP.txt ./data/cmd/$NAME/$TIMESTAMP.txt
mkdir -p ./data/$PREFIX/$TYPE/$CLIENT-$RPS-$DURATION
go run ./parse/main.go -name $NAME -timestamp $TIMESTAMP -input ./data/input -output ./data/output

echo "NAME: $NAME"
echo "CMD: $CMD"
echo "TIMESTAMP: $TIMESTAMP"
6 changes: 2 additions & 4 deletions consumption/collect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@ import (
)

func main() {
dir := flag.String("dir", "", "directory to save data")
name := flag.String("name", "", "project name")
timestamp := flag.String("timestamp", "", "timestamp to exec command (RFC3339)")
interval := flag.Int("interval", 10, "interval to exec command (second)")
duration := flag.Int("duration", 300, "duration to exec command (second)")
flag.Parse()
cmd := flag.Args()

fmt.Printf("dir: %s\n", *dir)
fmt.Printf("name: %s\n", *name)
fmt.Printf("timestamp: %s\n", *timestamp)
fmt.Printf("interval: %d\n", *interval)
fmt.Printf("duration: %d\n", *duration)
fmt.Printf("cmd: %s\n", strings.Join(cmd, " "))

if len(*dir) == 0 || len(*name) == 0 || *interval == 0 || *duration == 0 || len(cmd) < 2 || len(*timestamp) == 0 {
if len(*name) == 0 || *interval == 0 || *duration == 0 || len(cmd) < 2 || len(*timestamp) == 0 {
flag.Usage()
return
}
Expand All @@ -44,7 +42,7 @@ func main() {
cancel()
}()

dirname := filepath.Join(*dir, *name, *timestamp)
dirname := filepath.Join(*name, *timestamp)
if _, err := os.Stat(dirname); err == nil {
fmt.Printf("duplicated timestamp: %s\n", dirname)
return
Expand Down
26 changes: 0 additions & 26 deletions consumption/exec-cmd.sh

This file was deleted.

51 changes: 0 additions & 51 deletions consumption/kubernetes/manifests/proxy-http.yaml

This file was deleted.

51 changes: 0 additions & 51 deletions consumption/kubernetes/manifests/proxy-picop.yaml

This file was deleted.

24 changes: 13 additions & 11 deletions consumption/restart.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash -eux
#!/bin/bash -ux

# # dsb-hr namespaceのdeploymentのname一覧を取得
# deployments=$(kubectl get deployments -n dsb-hr -o jsonpath='{.items[*].metadata.name}')
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

# # 取得したdeploymentそれぞれでkubectl rollout restartコマンドを実行
# for deployment in $deployments
# do
# kubectl rollout restart deployment/$deployment -n dsb-hr
# echo "Restarted deployment: $deployment"
# done
cd ../kubernetes/manifests

kubectl delete -Rf ./kubernetes/manifests
kubectl apply -Rf ./kubernetes/manifests
kubectl delete -f namespace.yaml
kubectl apply -f namespace.yaml
kubectl apply -f proxy-both.yaml
./script/create-service.sh http main 32001 | kubectl -n service apply -f -
./script/create-service.sh http main 32002 | kubectl -n service-istio apply -f -

0 comments on commit e172e1a

Please sign in to comment.