Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from kinvolk/t-lo/configure-nr-of-threads-indep…
Browse files Browse the repository at this point in the history
…endent-of-nr-of-instances

scripts: introduce configurable number of load gen threads
  • Loading branch information
t-lo authored May 27, 2019
2 parents 440554c + 494c0e4 commit 7bce770
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 24 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ Before continuing, make sure the `KUBECONFIG` environment variable points to
the kubernetes configuration of the correct cluster.

You're now set up to start a benchmark. You may specify the number of apps in
the cluster, the benchmark run time, and the requests per second via the
the cluster, the benchmark run time, the requests per second, and the number of
parallel connections / threads used by the benchmark load generator via the
command line.

The following example starts a linkerd benchmark running 5 minutes, with 10
apps and a constant request rate of 100RPS:
* `scripts/linkerd/benchmark.sh 10 5m 100`
apps a constant request rate of 100RPS, using 8 load generator threads:
* `scripts/linkerd/benchmark.sh 10 5m 100 8`

If you want to run a full series of benchmarks for linkerd, istio stock, istio
tuned, and bare, simply issue:
* `scripts/linkerd/benchark-multi.sh 10 5m 100`
* `scripts/linkerd/benchark-multi.sh 10 5m 100 8`

Please note that you must always use scripts from the directory of your
respective cluster service mesh. If your cluster currently has istio installed,
Expand Down
4 changes: 3 additions & 1 deletion scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ function run_benchmark() {
local log_dir="${BENCHMARK_LOGFILE_DIR:-.}/"
local duration=${4:-30m}
local rate=${5:-800}
local threads=${6:-8}

local script_dir=$(dirname ${BASH_SOURCE[0]})
local template="${script_dir}/../wrk2/wrk2.yaml.tmpl"
Expand All @@ -300,7 +301,8 @@ function run_benchmark() {

${script_dir}/../wrk2/render.sh --instances $instances \
--duration $duration \
--rate $rate > $deployment
--rate $rate \
--threads $threads > $deployment

echo "Injecting service mesh via '$inject $deployment'"
$inject $deployment > $deployment_injected
Expand Down
15 changes: 9 additions & 6 deletions scripts/istio/benchmark-multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ duration="30m"
rate="800"
[ $# -ge 3 ] && rate="$3"

istioctl=$(grok_cmd 4 "istioctl" $@)
threads="8"
[ $# -ge 4 ] && threads="$4"

istioctl=$(grok_cmd 5 "istioctl" $@)
[ -z $istioctl ] && { echo "Aborting."; exit 1; }

linkerd=$(grok_cmd 5 "linkerd2-cli-edge-19.5.3-linux" $@)
linkerd=$(grok_cmd 6 "linkerd2-cli-edge-19.5.3-linux" $@)
[ -z $linkerd ] && { echo "Aborting."; exit 1; }

### Istio tuned
echo
echo "##### Running $istioctl benchmark (tuned)"
${script_dir}/benchmark.sh $nr_apps "$duration" "$rate" $istioctl "tuned"
${script_dir}/benchmark.sh $nr_apps "$duration" "$rate" "$threads" $istioctl "tuned"

echo "##### Removing tuned istio and installing stock istio"
${script_dir}/cleanup-istio.sh
Expand All @@ -47,7 +50,7 @@ STOCK_MODE=1 ${script_dir}/setup-cluster.sh $istioctl

echo
echo "##### Running $istioctl benchmark"
${script_dir}/benchmark.sh $nr_apps "$duration" "$rate" $istioctl "stock"
${script_dir}/benchmark.sh $nr_apps "$duration" "$rate" "$threads" $istioctl "stock"

echo "##### Removing istio and installing linkerd"
${script_dir}/cleanup-istio.sh
Expand All @@ -56,7 +59,7 @@ ${script_dir}/cleanup-istio.sh
${script_dir}/../linkerd/setup-cluster.sh $linkerd

echo "##### Running $linkerd benchmark"
${script_dir}/../linkerd/benchmark.sh $nr_apps "$duration" "$rate" $linkerd
${script_dir}/../linkerd/benchmark.sh $nr_apps "$duration" "$rate" "$threads" $linkerd

echo "##### Removing linkerd"
${script_dir}/../linkerd/cleanup-linkerd.sh
Expand All @@ -71,7 +74,7 @@ install_emojivoto "cat" $nr_apps
wait_namespace_settled emojivoto

echo "##### Running bare benchmark"
run_benchmark "bare" $nr_apps "cat" "$duration" "$rate"
run_benchmark "bare" $nr_apps "cat" "$duration" "$rate" "$threads"

echo "##### removing bare emojivoto"
kubectl delete -f emojivoto.injected.yaml --wait=true --grace-period=1 --all=true || true
Expand Down
9 changes: 6 additions & 3 deletions scripts/istio/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ duration="30m"
rate="800"
[ $# -ge 3 ] && rate="$3"

istioctl=$(grok_cmd 4 "istioctl" $@)
threads="8"
[ $# -ge 4 ] && threads="$4"

istioctl=$(grok_cmd 5 "istioctl" $@)
[ -z $istioctl ] && { echo "Aborting."; exit 1; }

istio_type="tuned"
[ $# -ge 5 ] && istio_type="$5"
[ $# -ge 6 ] && istio_type="$6"

asset_dir="${script_dir}/../../assets"
KUBECONFIG=$(print_kubeconfig_path "$asset_dir")
Expand All @@ -40,7 +43,7 @@ install_emojivoto "$istioctl kube-inject -f" $nr_apps
echo "Sleeping for $((5*nr_apps)) seconds to let injected apps settle some more."
sleep $((5*nr_apps))

run_benchmark "istio-${istio_type}" $nr_apps "$istioctl kube-inject -f" "$duration" "$rate"
run_benchmark "istio-${istio_type}" $nr_apps "$istioctl kube-inject -f" "$duration" "$rate" "$threads"

echo "### Cleaning up..."
kubectl delete -f emojivoto.injected.yaml --wait=true --grace-period=1 --all=true || true
Expand Down
15 changes: 9 additions & 6 deletions scripts/linkerd/benchmark-multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ duration="30m"
rate="800"
[ $# -ge 3 ] && rate="$3"

linkerd=$(grok_cmd 4 "linkerd2-cli-edge-19.5.3-linux" $@)
threads="8"
[ $# -ge 4 ] && threads="$4"

linkerd=$(grok_cmd 5 "linkerd2-cli-edge-19.5.3-linux" $@)
[ -z $linkerd ] && { echo "Aborting."; exit 1; }

istioctl=$(grok_cmd 5 "istioctl" $@)
istioctl=$(grok_cmd 6 "istioctl" $@)
[ -z $istioctl ] && { echo "Aborting."; exit 1; }


### Linkerd
echo "##### Running $linkerd benchmark"
${script_dir}/benchmark.sh $nr_apps $duration $rate $linkerd
${script_dir}/benchmark.sh $nr_apps $duration $rate $threads $linkerd

echo "##### Removing linkerd and installing istio tuned"
${script_dir}/cleanup-linkerd.sh
Expand All @@ -46,7 +49,7 @@ STOCK_MODE=0 ${script_dir}/../istio/setup-cluster.sh $istioctl

echo
echo "##### Running $istioctl benchmark (tuned)"
${script_dir}/../istio/benchmark.sh $nr_apps $duration $rate $istioctl "tuned"
${script_dir}/../istio/benchmark.sh $nr_apps $duration $rate $threads $istioctl "tuned"

echo "##### Removing istio tuned and installing istio stock"
${script_dir}/../istio/cleanup-istio.sh
Expand All @@ -57,7 +60,7 @@ STOCK_MODE=1 ${script_dir}/../istio/setup-cluster.sh $istioctl

echo
echo "##### Running $istioctl benchmark (stock)"
${script_dir}/../istio/benchmark.sh $nr_apps $duration $rate $istioctl "stock"
${script_dir}/../istio/benchmark.sh $nr_apps $duration $rate $threads $istioctl "stock"

echo "##### Removing istio"
${script_dir}/../istio/cleanup-istio.sh
Expand All @@ -71,7 +74,7 @@ taint_random_worker_node "$nr_apps" "reserved-for-benchmark-load-generator"
install_emojivoto "cat" $nr_apps

echo "##### Running bare benchmark"
run_benchmark "bare" $nr_apps "cat" "$duration" "$rate"
run_benchmark "bare" $nr_apps "cat" "$duration" "$rate" "$threads"

echo "##### removing bare emojivoto"
kubectl delete -f emojivoto.injected.yaml --wait=true --grace-period=1 --all=true || true
Expand Down
7 changes: 5 additions & 2 deletions scripts/linkerd/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ duration="30m"
rate="800"
[ $# -ge 3 ] && rate="$3"

linkerd=$(grok_cmd 4 "linkerd2-cli-edge-19.5.3-linux" $@)
threads="8"
[ $# -ge 4 ] && threads="$4"

linkerd=$(grok_cmd 5 "linkerd2-cli-edge-19.5.3-linux" $@)
[ -z $linkerd ] && { echo "Aborting."; exit 1; }

asset_dir="${script_dir}/../../assets"
Expand All @@ -40,7 +43,7 @@ clear
echo "Sleeping for $((5*nr_apps)) seconds to let injected apps settle some more."
sleep $((5*nr_apps))

run_benchmark "linkerd" $nr_apps "$linkerd inject --manual" "$duration" "$rate"
run_benchmark "linkerd" $nr_apps "$linkerd inject --manual" "$duration" "$rate" "$threads"

echo "### Cleaning up..."
kubectl delete -f emojivoto.injected.yaml --wait=true --grace-period=1 --all=true || true
Expand Down
8 changes: 8 additions & 0 deletions wrk2/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export IMAGE=quay.io/kinvolk/wrk2:latest
export DURATION=5m
export RATE=1500
export INSTANCES=8
export THREADS=8

usage() {
cat <<HELP_USAGE
Expand All @@ -20,6 +21,8 @@ Usage: $0 [OPTION...]
-d, --duration Duration of benchmark.
-r, --rate Requests per second for each instance.
-I, --instances Number of instances.
-t, --threads Number of parallel threads/connections to use.
Each thread will use a single connection.
-h --help Prints this message.
HELP_USAGE
}
Expand Down Expand Up @@ -52,6 +55,11 @@ case $key in
shift # past argument
shift # past value
;;
-t|--threads)
export THREADS="$2"
shift # past argument
shift # past value
;;
*)
echo "Unknown argument $1"
usage
Expand Down
4 changes: 2 additions & 2 deletions wrk2/wrk2.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ spec:
- -R
- "${RATE}"
- -c
- "${INSTANCES}"
- "${THREADS}"
- -t
- "${INSTANCES}"
- "${THREADS}"
- --latency
- --timeout
- "5000"
Expand Down

0 comments on commit 7bce770

Please sign in to comment.