фикс из пр
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p evidence/scale/growing
|
||||
for replicas in 1 2 4; do
|
||||
export API_REPLICAS="$replicas"
|
||||
export API_CPUS=1.0
|
||||
export API_MEMORY=512m
|
||||
docker compose -f compose.yaml -f compose.scale.yaml down
|
||||
services=(postgres redis migrate nginx)
|
||||
for ((i=1;i<=replicas;i++)); do services+=("api-$i"); done
|
||||
docker compose -f compose.yaml -f compose.scale.yaml up -d --build "${services[@]}"
|
||||
for ((attempt=1;attempt<=60;attempt++)); do
|
||||
if curl --fail --silent http://localhost:8080/health/ready >/dev/null; then break; fi
|
||||
sleep 2
|
||||
done
|
||||
curl --fail --silent http://localhost:8080/health/ready >/dev/null
|
||||
for ((i=1;i<=replicas;i++)); do
|
||||
docker compose -f compose.yaml -f compose.scale.yaml ps "api-$i"
|
||||
done
|
||||
python3 tests/load.py --duration 15 --concurrency 16 --output "evidence/scale/growing/replicas-${replicas}-warmup.json"
|
||||
for run in 1 2 3; do
|
||||
python3 tests/load.py --duration 60 --concurrency 16 --output "evidence/scale/growing/replicas-${replicas}-run${run}.json"
|
||||
done
|
||||
done
|
||||
API_REPLICAS=2 API_CPUS=1.0 API_MEMORY=512m docker compose -f compose.yaml -f compose.scale.yaml down
|
||||
API_REPLICAS=2 API_CPUS=1.0 API_MEMORY=512m docker compose -f compose.yaml -f compose.scale.yaml up -d --build postgres redis migrate api-1 api-2 nginx
|
||||
python3 scripts/summarize_growing_scale.py
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p evidence/scale/optimization
|
||||
|
||||
run_case() {
|
||||
local name="$1"
|
||||
local replicas="$2"
|
||||
local cpus="$3"
|
||||
local memory="$4"
|
||||
|
||||
export API_REPLICAS="$replicas"
|
||||
export API_CPUS="$cpus"
|
||||
export API_MEMORY="$memory"
|
||||
|
||||
echo "=== $name: $replicas replicas, $cpus CPU and $memory per replica ==="
|
||||
|
||||
docker compose -f compose.yaml -f compose.scale.yaml down
|
||||
|
||||
services=(postgres redis migrate nginx)
|
||||
for ((i=1; i<=replicas; i++)); do
|
||||
services+=("api-$i")
|
||||
done
|
||||
|
||||
docker compose -f compose.yaml -f compose.scale.yaml up -d --build "${services[@]}"
|
||||
|
||||
ready=0
|
||||
for ((attempt=1; attempt<=60; attempt++)); do
|
||||
if curl --fail --silent http://localhost:8080/health/ready >/dev/null; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if ((ready == 0)); then
|
||||
echo "ERROR: API readiness timeout" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 tests/load.py \
|
||||
--duration 15 \
|
||||
--concurrency 16 \
|
||||
--output "evidence/scale/optimization/${name}-warmup.json"
|
||||
|
||||
for run in 1 2 3; do
|
||||
python3 tests/load.py \
|
||||
--duration 60 \
|
||||
--concurrency 16 \
|
||||
--output "evidence/scale/optimization/${name}-run${run}.json"
|
||||
done
|
||||
}
|
||||
|
||||
run_case before 4 0.5 256m
|
||||
run_case after 2 1.0 512m
|
||||
|
||||
API_REPLICAS=2 API_CPUS=1.0 API_MEMORY=512m \
|
||||
docker compose -f compose.yaml -f compose.scale.yaml down
|
||||
|
||||
API_REPLICAS=2 API_CPUS=1.0 API_MEMORY=512m \
|
||||
docker compose -f compose.yaml -f compose.scale.yaml up -d --build \
|
||||
postgres redis migrate api-1 api-2 nginx
|
||||
|
||||
echo "=== Optimization experiment completed ==="
|
||||
@@ -0,0 +1,17 @@
|
||||
import json
|
||||
import statistics
|
||||
from pathlib import Path
|
||||
|
||||
root = Path('evidence/scale/growing')
|
||||
print('Growing budget: 1/2/4 replicas, each 1 CPU and 512 MiB, 16 clients, 60 seconds, 3 runs')
|
||||
for replicas in (1, 2, 4):
|
||||
files = [root / f'replicas-{replicas}-run{i}.json' for i in (1, 2, 3)]
|
||||
if not all(p.exists() for p in files):
|
||||
print(f'{replicas}: INCOMPLETE (measurements not yet run)')
|
||||
continue
|
||||
data = [json.loads(p.read_text()) for p in files]
|
||||
values = [x['successful_rps'] for x in data]
|
||||
errors = sum(x['failed_requests'] for x in data)
|
||||
print(f'{replicas}: mean RPS={statistics.mean(values):.3f}, stdev={statistics.stdev(values):.3f}, '
|
||||
f'mean p95={statistics.mean(x["successful_latency_ms"]["p95"] for x in data):.3f} ms, '
|
||||
f'mean p99={statistics.mean(x["successful_latency_ms"]["p99"] for x in data):.3f} ms, errors={errors}')
|
||||
Reference in New Issue
Block a user