Repeat detection, add track 1 control runs and isolate image tags
BASE_URL defaults to the published port of lb from docker compose, so the targets work with a changed LB_HTTP_PORT. rolling-update FROM_REV and track1-compare tag the old revision by its commit instead of the shared mtusi-messenger tag, which a parallel clone could overwrite. detection runs three times to show the spread, failover-each records docker ps -a of the replicas right after the stop, and failover-evidence takes SHIFT to move round robin to the other replica. track1-control varies the pool and the balancer queue at 8x1 and compares 8x0.5 with 4x1 on the same CPUs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
16b6b28ea9
commit
956d24a701
@@ -1,5 +1,5 @@
|
|||||||
PYTHON ?= python3
|
PYTHON ?= python3
|
||||||
BASE_URL ?= http://localhost:8080
|
BASE_URL ?= http://$(shell docker compose port lb 8080 2>/dev/null || echo localhost:8080)
|
||||||
CA_FILE ?=
|
CA_FILE ?=
|
||||||
ACTION_SCRIPT ?=
|
ACTION_SCRIPT ?=
|
||||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||||
@@ -8,8 +8,8 @@ VENV ?= .venv
|
|||||||
UV ?= uv
|
UV ?= uv
|
||||||
COMPOSE ?= docker compose
|
COMPOSE ?= docker compose
|
||||||
RATE ?= 100
|
RATE ?= 100
|
||||||
API_IMAGE ?= mtusi-messenger:lab3
|
|
||||||
FROM_REV ?=
|
FROM_REV ?=
|
||||||
|
SHIFT ?= 0
|
||||||
SCRIPTS_PY = scripts/probe.py scripts/limits.py scripts/scaling.py tools
|
SCRIPTS_PY = scripts/probe.py scripts/limits.py scripts/scaling.py tools
|
||||||
TRACK1 = evidence/track1
|
TRACK1 = evidence/track1
|
||||||
SCALING = $(PYTHON) scripts/scaling.py --fresh-db
|
SCALING = $(PYTHON) scripts/scaling.py --fresh-db
|
||||||
@@ -21,7 +21,7 @@ PSQL = $(COMPOSE) exec -T postgres psql -U messenger -d messenger -X -q
|
|||||||
secrets up down reset-data migrate ps logs restore lb-check failover-evidence stack-evidence \
|
secrets up down reset-data migrate ps logs restore lb-check failover-evidence stack-evidence \
|
||||||
persistence-evidence storage-evidence cache-evidence test-faults seed explain \
|
persistence-evidence storage-evidence cache-evidence test-faults seed explain \
|
||||||
limits detection failover-each rolling-update level4 \
|
limits detection failover-each rolling-update level4 \
|
||||||
track1 track1-host track1-a track1-b track1-compare plots
|
track1 track1-host track1-a track1-b track1-compare track1-control plots
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||||
@@ -29,7 +29,8 @@ help:
|
|||||||
@echo "secrets/up/down/migrate/ps/logs: стенд Docker Compose; reset-data: намеренное удаление volumes"
|
@echo "secrets/up/down/migrate/ps/logs: стенд Docker Compose; reset-data: намеренное удаление volumes"
|
||||||
@echo "restore: вернуть остановленные реплики; lb-check: реплики на одном токене и 20 гонок одного ключа"
|
@echo "restore: вернуть остановленные реплики; lb-check: реплики на одном токене и 20 гонок одного ключа"
|
||||||
@echo "level4 = limits, lb-check, detection, failover-each, rolling-update [FROM_REV=<коммит>]; RATE=$(RATE) rps"
|
@echo "level4 = limits, lb-check, detection, failover-each, rolling-update [FROM_REV=<коммит>]; RATE=$(RATE) rps"
|
||||||
@echo "track1 = track1-host, track1-a (1x4/2x2/4x1), track1-b (1x1/2x1/8x1), track1-compare [BEFORE_REV=$(BEFORE_REV)], plots → $(TRACK1)"
|
@echo "track1 = track1-host, track1-a (1x4/2x2/4x1), track1-b (1x1/2x1/8x1), track1-compare [BEFORE_REV=$(BEFORE_REV)], track1-control, plots → $(TRACK1)"
|
||||||
|
@echo "BASE_URL=$(BASE_URL) (порт lb из docker compose); failover-evidence SHIFT=1 — сдвиг round robin на вторую реплику"
|
||||||
|
|
||||||
check:
|
check:
|
||||||
$(PYTHON) scripts/check_contract.py
|
$(PYTHON) scripts/check_contract.py
|
||||||
@@ -101,15 +102,16 @@ limits:
|
|||||||
$(PYTHON) scripts/limits.py --out evidence/limits.txt
|
$(PYTHON) scripts/limits.py --out evidence/limits.txt
|
||||||
|
|
||||||
detection:
|
detection:
|
||||||
sh scripts/detection.sh evidence/detection
|
rm -rf evidence/detection
|
||||||
|
for run in 1 2 3; do sh scripts/detection.sh evidence/detection/run$$run || exit 1; done
|
||||||
|
|
||||||
failover-each:
|
failover-each:
|
||||||
RATE=$(RATE) sh scripts/failover-each.sh evidence/failover-each
|
RATE=$(RATE) sh scripts/failover-each.sh evidence/failover-each
|
||||||
|
|
||||||
rolling-update:
|
rolling-update:
|
||||||
ifneq ($(FROM_REV),)
|
ifneq ($(FROM_REV),)
|
||||||
git archive "$(FROM_REV)" | docker build -q -t "$(API_IMAGE)" -
|
git archive "$(FROM_REV)" | docker build -q -t "mtusi-messenger:$(FROM_REV)" -
|
||||||
$(COMPOSE) up -d --no-deps --force-recreate --wait api
|
API_IMAGE="mtusi-messenger:$(FROM_REV)" $(COMPOSE) up -d --no-deps --force-recreate --wait api
|
||||||
scripts/lb-wait.sh
|
scripts/lb-wait.sh
|
||||||
endif
|
endif
|
||||||
$(COMPOSE) build -q api
|
$(COMPOSE) build -q api
|
||||||
@@ -119,7 +121,7 @@ endif
|
|||||||
|
|
||||||
level4: limits lb-check detection failover-each rolling-update
|
level4: limits lb-check detection failover-each rolling-update
|
||||||
|
|
||||||
track1: track1-host track1-a track1-b track1-compare plots
|
track1: track1-host track1-a track1-b track1-compare track1-control plots
|
||||||
|
|
||||||
track1-host:
|
track1-host:
|
||||||
sh scripts/host-snapshot.sh $(TRACK1)/host.txt
|
sh scripts/host-snapshot.sh $(TRACK1)/host.txt
|
||||||
@@ -133,17 +135,24 @@ track1-b:
|
|||||||
--start-per-cpu 450 --search 1.5:9000
|
--start-per-cpu 450 --search 1.5:9000
|
||||||
|
|
||||||
track1-compare:
|
track1-compare:
|
||||||
git archive "$(BEFORE_REV)" | docker build -q -t mtusi-messenger:before -
|
git archive "$(BEFORE_REV)" | docker build -q -t mtusi-messenger:$(BEFORE_REV) -
|
||||||
$(COMPOSE) build -q api
|
$(COMPOSE) build -q api
|
||||||
$(SCALING) --out $(TRACK1)/compare --configs 8x1 --api-memory 512 --rates 3600,5400,8100 \
|
$(SCALING) --out $(TRACK1)/compare --configs 8x1 --api-memory 512 --rates 3600,5400,8100 \
|
||||||
--variant before:API_IMAGE=mtusi-messenger:before --variant after
|
--variant before:API_IMAGE=mtusi-messenger:$(BEFORE_REV) --variant after
|
||||||
|
|
||||||
|
track1-control:
|
||||||
|
$(SCALING) --out $(TRACK1)/control-pool --configs 8x1 --api-memory 512 --rates 5400 \
|
||||||
|
--variant pool4:DB_POOL_MAX_SIZE=4 --variant pool8 --variant pool16:DB_POOL_MAX_SIZE=16 \
|
||||||
|
--variant maxconn16:API_SERVER_MAXCONN=16 --variant maxconn64:API_SERVER_MAXCONN=64
|
||||||
|
$(SCALING) --out $(TRACK1)/control-cpus --configs 4x1,8x0.5 --api-memory 512 --rates 4560,6830 \
|
||||||
|
--variant pinned
|
||||||
|
|
||||||
plots:
|
plots:
|
||||||
MPLBACKEND=Agg $(UV) run --no-project --python 3.14 --with 'matplotlib==3.11.2' \
|
MPLBACKEND=Agg $(UV) run --no-project --python 3.14 --with 'matplotlib==3.11.2' \
|
||||||
python tools/plot_track1.py --out $(TRACK1)/plots $(wildcard $(TRACK1)/*/summary.csv)
|
python tools/plot_track1.py --out $(TRACK1)/plots $(wildcard $(TRACK1)/*/summary.csv)
|
||||||
|
|
||||||
failover-evidence:
|
failover-evidence:
|
||||||
sh scripts/failover-evidence.sh "$(BASE_URL)"
|
sh scripts/failover-evidence.sh "$(BASE_URL)" "$(SHIFT)"
|
||||||
|
|
||||||
stack-evidence:
|
stack-evidence:
|
||||||
sh scripts/evidence-stack.sh
|
sh scripts/evidence-stack.sh
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
## 2. Обвязка
|
## 2. Обвязка
|
||||||
|
|
||||||
- [ ] 2.1 `Makefile`: `BASE_URL` по порту `lb`, `API_IMAGE` по каталогу, `detection` трижды, `track1-control`
|
- [x] 2.1 `Makefile`: `BASE_URL` по порту `lb`, `API_IMAGE` по каталогу, `detection` трижды, `track1-control`
|
||||||
- [x] 2.2 `scripts/evidence-storage.sh` — volumes своего проекта; `scripts/limits.py` — коммит в заголовке
|
- [x] 2.2 `scripts/evidence-storage.sh` — volumes своего проекта; `scripts/limits.py` — коммит в заголовке
|
||||||
- [x] 2.3 `scripts/scaling.py` — полный stderr сбоя `compose up` в `compose-up-failed.log`
|
- [x] 2.3 `scripts/scaling.py` — полный stderr сбоя `compose up` в `compose-up-failed.log`
|
||||||
- [ ] 2.4 `scripts/failover-each.sh` — `docker ps -a` реплик после хука; `scripts/failover-evidence.sh` — `SHIFT`
|
- [x] 2.4 `scripts/failover-each.sh` — `docker ps -a` реплик после хука; `scripts/failover-evidence.sh` — `SHIFT`
|
||||||
- [ ] 2.5 Проверка группы: `make lint`, `make check`, `bash -n`/`sh -n` скриптов
|
- [x] 2.5 Проверка группы: `make lint`, `make check`, `bash -n`/`sh -n` скриптов
|
||||||
|
|
||||||
## 3. Доказательства на итоговом коде
|
## 3. Доказательства на итоговом коде
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ failed=0
|
|||||||
set --
|
set --
|
||||||
for host in $hosts; do
|
for host in $hosts; do
|
||||||
TARGET_INSTANCE_ID=$host python3 scripts/probe.py load --expect dip --out "$out/$host" \
|
TARGET_INSTANCE_ID=$host python3 scripts/probe.py load --expect dip --out "$out/$host" \
|
||||||
-- sh -c "scripts/stop-one.sh && sleep ${HOLD:-10} && scripts/restore.sh" || failed=1
|
-- sh -c "scripts/stop-one.sh && docker compose ps -a --format '{{.ID}} {{.Service}} {{.Status}}' ${API_SERVICE:-api} && sleep ${HOLD:-10} && scripts/restore.sh" || failed=1
|
||||||
scripts/restore.sh
|
scripts/restore.sh
|
||||||
set -- "$@" "$out/$host/result.json"
|
set -- "$@" "$out/$host/result.json"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ cd "$(dirname "$0")/.."
|
|||||||
replicas() {
|
replicas() {
|
||||||
docker inspect -f '{{.Config.Hostname}} {{.State.Status}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' $(docker compose ps -aq "${API_SERVICE:-api}")
|
docker inspect -f '{{.Config.Hostname}} {{.State.Status}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' $(docker compose ps -aq "${API_SERVICE:-api}")
|
||||||
}
|
}
|
||||||
|
url=${1:-http://localhost:8080}
|
||||||
|
shift=0
|
||||||
|
while [ "$shift" -lt "${2:-0}" ]; do curl -fsS -o /dev/null "$url/health/live"; shift=$((shift + 1)); done
|
||||||
tmp=evidence/failover.tmp
|
tmp=evidence/failover.tmp
|
||||||
since=$(date -u +%FT%TZ)
|
since=$(date -u +%FT%TZ)
|
||||||
{
|
{
|
||||||
@@ -11,7 +14,7 @@ since=$(date -u +%FT%TZ)
|
|||||||
echo "== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt"
|
echo "== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt"
|
||||||
replicas
|
replicas
|
||||||
echo "\$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh"
|
echo "\$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh"
|
||||||
make --no-print-directory test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL="${1:-http://localhost:8080}"
|
make --no-print-directory test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL="$url"
|
||||||
echo "== after: api replicas"
|
echo "== after: api replicas"
|
||||||
replicas
|
replicas
|
||||||
} > "$tmp" 2>&1
|
} > "$tmp" 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user