62 lines
2.8 KiB
Bash
Executable File
62 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# Track 1, the cost of scaling: runs every configuration of one series file,
|
|
# each repeated, each on a fresh stand (empty volumes, same seed), under the
|
|
# same grid of offered rates.
|
|
#
|
|
# RATES=200,400,800 sh scripts/bench/run-series.sh scripts/bench/series/A.conf [repeats]
|
|
#
|
|
# Environment: RATES (required), STEP (30s), WARMUP (30s), OUT (results root,
|
|
# default evidence/track1/raw). Fixed for every configuration: HAProxy
|
|
# LB_CPUS (1.0), PostgreSQL PG_CPUS/PG_MEMORY (1.0/1G), Valkey 0.5 CPU and the
|
|
# generator LOADGEN_CPUS (1.5). Results per run:
|
|
# <OUT>/<series>/<config>/rep<k>/{meta.json,steps.json,seconds.csv,
|
|
# metrics.jsonl,docker-stats.jsonl,postgres.jsonl,loadgen.log}
|
|
# The stand is removed at the end; `make up` brings the normal one back.
|
|
set -eu
|
|
cd "$(dirname "$0")/../.."
|
|
. scripts/bench/lib.sh
|
|
|
|
series=${1:?usage: run-series.sh <series.conf> [repeats]}
|
|
repeats=${2:-3}
|
|
: "${RATES:?set RATES, the offered requests per second of the steps, e.g. 200,400,800}"
|
|
step=${STEP:-30s}
|
|
warmup=${WARMUP:-30s}
|
|
root=${OUT:-evidence/track1/raw}/$(basename "$series" .conf)
|
|
|
|
export APP_DEBUG_ADDR=:9090 LB_QUIET=1
|
|
export LB_CPUS=${LB_CPUS:-1.0} PG_CPUS=${PG_CPUS:-1.0} PG_MEMORY=${PG_MEMORY:-1G} LOADGEN_CPUS=${LOADGEN_CPUS:-1.5}
|
|
export MSYS_NO_PATHCONV=1
|
|
|
|
grep -v '^#' "$series" | while read -r name replicas cpus memory gomemlimit pool; do
|
|
[ -n "$name" ] || continue
|
|
for rep in $(seq 1 "$repeats"); do
|
|
dir=$root/$name/rep$rep
|
|
rm -rf "$dir"
|
|
mkdir -p "$dir"
|
|
echo "== $name rep $rep: $replicas x $cpus CPU / $memory, pool $pool, rates $RATES"
|
|
export API_REPLICAS=$replicas API_CPUS=$cpus API_MEMORY=$memory API_GOMEMLIMIT=$gomemlimit DB_MAX_CONNS=$pool
|
|
|
|
docker compose down -v --remove-orphans >/dev/null 2>&1
|
|
docker compose up -d --build --wait >/dev/null 2>&1
|
|
meta "$dir/meta.json" "series=$(basename "$series" .conf)" "config=$name" "repeat=$rep" \
|
|
"api_replicas=$replicas" "api_cpus=$cpus" "api_memory=$memory" "gomemlimit=$gomemlimit" "db_max_conns=$pool" \
|
|
"lb_cpus=$LB_CPUS" "pg_cpus=$PG_CPUS" "pg_memory=$PG_MEMORY" "loadgen_cpus=$LOADGEN_CPUS" \
|
|
"rates=$RATES" "step=$step" "warmup=$warmup"
|
|
|
|
sample_docker_stats "$dir/docker-stats.jsonl" &
|
|
stats=$!
|
|
sample_postgres "$dir/postgres.jsonl" &
|
|
pg=$!
|
|
# stdin is closed: `compose run` is interactive by default and would
|
|
# otherwise read the rest of the series file this loop is reading.
|
|
BENCH_OUT=$(abspath "$dir") docker compose --profile bench run --rm loadgen bench \
|
|
-rates "$RATES" -step "$step" -warmup "$warmup" -scrape >"$dir/loadgen.log" 2>&1 </dev/null ||
|
|
echo " loadgen failed, see $dir/loadgen.log"
|
|
kill "$stats" "$pg" 2>/dev/null || true
|
|
wait "$stats" "$pg" 2>/dev/null || true
|
|
cat "$dir/loadgen.log" | grep '^step' || true
|
|
done
|
|
done
|
|
docker compose down -v --remove-orphans >/dev/null 2>&1
|
|
echo "results in $root"
|