Feat: add qps for load test client (#5733)

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2023-03-24 18:04:18 +08:00
committed by GitHub
parent de790e6fae
commit 9dc0db4cfc
2 changed files with 10 additions and 2 deletions

View File

@@ -41,6 +41,10 @@ Set `CLUSTER=3` will inject the `CLUSTER` variable to the app template. You can
> To make multicluster load testing environment, you can set up multiple k3d instances and register them in the control plane.
#### QPS
By default, there is no rate limit for the client. If you want to set the QPS for each worker, you can use `QPS=2`.
### Cleanup
Run `SHARD=3 WORKER=4 BEGIN=0 SIZE=1000 bash cleanup.sh` to delete `app-0` to `app-999` from namespace `load-test-0` to `load-test-2` in 4 threads.

View File

@@ -5,6 +5,7 @@ SIZE=${SIZE:-1000}
WORKER=${WORKER:-6}
VERSION=${VERSION:-1}
CLUSTER=${CLUSTER:-4}
QPS=${QPS:-1}
SHARD=${SHARD:-3}
@@ -12,6 +13,8 @@ TEMPLATE=${TEMPLATE:-"light"}
END=$(expr $BEGIN + $SIZE - 1)
waitTime=$(expr 1000 / $QPS)e-3
run() {
for i in $(seq $1 $3 $2); do
sid=$(expr $i % $SHARD)
@@ -24,6 +27,7 @@ run() {
sed 's/CLUSTER/'$c'/g' | \
kubectl apply -f -
echo "worker $4: apply app $i to $sid"
sleep $waitTime
done
echo "worker $4: done"
}