forked from mtusi2026/mtusi2026lab3
ops: add balanced replicated stack
This commit is contained in:
Executable
+104
@@ -0,0 +1,104 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
duration=${DURATION:-15s}
|
||||
warmup=${WARMUP:-3s}
|
||||
concurrencies=${CONCURRENCIES:-"8 32 64"}
|
||||
repeats=${REPEATS:-3}
|
||||
current_project=
|
||||
|
||||
restore_default_stack() {
|
||||
if [ -n "$current_project" ]; then
|
||||
env COMPOSE_PROJECT_NAME="$current_project" docker compose --profile research down -v --remove-orphans || true
|
||||
fi
|
||||
docker compose up -d --scale api=2 --wait --wait-timeout 120
|
||||
}
|
||||
|
||||
run_configuration() {
|
||||
series=$1
|
||||
replicas=$2
|
||||
api_cpus=$3
|
||||
api_memory=$4
|
||||
db_max_conns=$5
|
||||
repeat=$6
|
||||
point_concurrencies=$7
|
||||
project="lab3exp_${series}_r${replicas}_n${repeat}"
|
||||
|
||||
pending=false
|
||||
for concurrency in $point_concurrencies; do
|
||||
label="${series}-r${replicas}-c${concurrency}-n${repeat}"
|
||||
if [ ! -s "evidence/lab3-${label}.json" ]; then
|
||||
pending=true
|
||||
fi
|
||||
done
|
||||
if [ "$pending" = false ]; then
|
||||
echo "Skipping completed configuration ${series}-r${replicas}-n${repeat}"
|
||||
return
|
||||
fi
|
||||
|
||||
current_project=$project
|
||||
|
||||
compose() {
|
||||
env \
|
||||
COMPOSE_PROJECT_NAME="$project" \
|
||||
API_REPLICAS="$replicas" \
|
||||
API_CPUS="$api_cpus" \
|
||||
API_MEMORY="$api_memory" \
|
||||
DB_MIN_CONNS=0 \
|
||||
DB_MAX_CONNS="$db_max_conns" \
|
||||
docker compose "$@"
|
||||
}
|
||||
|
||||
compose up -d --scale api="$replicas" --wait --wait-timeout 120 \
|
||||
postgres valkey migrate api nginx postgres-exporter valkey-exporter nginx-exporter prometheus
|
||||
for concurrency in $point_concurrencies; do
|
||||
label="${series}-r${replicas}-c${concurrency}-n${repeat}"
|
||||
output="lab3-${label}.json"
|
||||
if [ -s "evidence/$output" ]; then
|
||||
echo "Skipping completed point $label"
|
||||
continue
|
||||
fi
|
||||
compose --profile research run --rm experiment \
|
||||
/app/lab3experiment \
|
||||
-base-url=http://nginx:8080 \
|
||||
-prometheus-url=http://prometheus:9090 \
|
||||
-label="$label" \
|
||||
-duration="$duration" \
|
||||
-warmup="$warmup" \
|
||||
-concurrency="$concurrency" \
|
||||
-replicas="$replicas" \
|
||||
-api-cpus="$api_cpus" \
|
||||
-api-memory="$api_memory" \
|
||||
-db-max-conns="$db_max_conns" \
|
||||
-output="/output/$output"
|
||||
done
|
||||
compose --profile research down -v --remove-orphans
|
||||
current_project=
|
||||
}
|
||||
|
||||
trap restore_default_stack EXIT INT TERM
|
||||
docker compose build api nginx swagger prometheus grafana
|
||||
docker compose stop
|
||||
|
||||
repeat=1
|
||||
while [ "$repeat" -le "$repeats" ]; do
|
||||
run_configuration fixed 1 2 1g 16 "$repeat" "$concurrencies"
|
||||
run_configuration fixed 2 1 512m 8 "$repeat" "$concurrencies"
|
||||
run_configuration fixed 4 0.5 256m 4 "$repeat" "$concurrencies"
|
||||
|
||||
run_configuration growing 1 1 256m 8 "$repeat" "$concurrencies"
|
||||
run_configuration growing 2 1 256m 8 "$repeat" "$concurrencies"
|
||||
run_configuration growing 4 1 256m 8 "$repeat" "$concurrencies"
|
||||
|
||||
run_configuration pool-baseline 4 0.5 256m 10 "$repeat" "64"
|
||||
run_configuration pool-tuned 4 0.5 256m 4 "$repeat" "64"
|
||||
repeat=$((repeat + 1))
|
||||
done
|
||||
|
||||
docker compose --profile research run --no-deps --rm experiment \
|
||||
/app/lab3summary \
|
||||
-input=/output \
|
||||
-output=/output/lab3-scale-results.json \
|
||||
-chart=/output/lab3-scale-rps.svg
|
||||
rm -f evidence/lab3-fixed-*.json evidence/lab3-growing-*.json evidence/lab3-pool-*.json
|
||||
Reference in New Issue
Block a user