forked from mtusi2026/mtusi2026lab2
The k6 profile from the prepared kit runs an open model against the balancer from the edge network: constant arrival rate, 80 % keyed message posts and 20 % history reads over 20 synthetic users and 10 chats, metrics only for the measure phase, and no setup data (tokens) in summary.json. scripts/k6.sh runs it with the host uid so the summary is writable on Linux too. scripts/probe.py gains three things. check --rounds repeats the same-key race with a new key per round and counts rounds with identical bodies, one stored copy and 409 on another body. load runs an action under k6 while a probe posts every 0.1 s and resends the same key after a failure and a poller reads the number of UP servers; it writes the action log, the probe and LB traces, the delta of the backend retry, redispatch and error counters, and a verdict: dip for a replica that leaves and returns, replace for a rolling update that must keep capacity and end on new replicas only. detect runs the action in the background and polls the balancer at the same time, so a drain that ends after the exclusion is visible, and checks the declared maximum, the LB answer after detection and the time to restore. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3.6 KiB
3.6 KiB
1. Остановка и готовность (платформа)
- 1.1
DRAININGвshared/entrypoints/health.py:/health/readyотвечает503 unavailable, пока флаг поднят - 1.2
DrainingServerиMessengerWorker._serveвgunicorn_conf.py: окноDRAIN_SECONDS, затем штатная остановка; uvicorn дообрабатываетSHUTDOWN_TIMEOUT_SECONDS − DRAIN_SECONDS - 1.3 Пинг readiness: 0,4 с на соединение и 0,4 с на запрос
- 1.4 Проверка группы: тесты — ready
503при флаге и live200; настоящий gunicorn поSIGTERMдержит окно, закрывает порт и выходит с кодом 0 за срок
2. Стенд и таймауты
- 2.1
compose.yaml: явныеDRAIN_SECONDS,DB_ACQUIRE_TIMEOUT_SECONDS,DB_COMMAND_TIMEOUT_SECONDSуapi; сервисk6под профилемbench;.env.example, Dockerfile - 2.2 Тест цепочки таймаутов по
compose.yaml,haproxy.cfgиscripts/stop-one.sh - 2.3 HAProxy
init-state fully-down: вернувшаяся через DNS реплика ждётrise 2проверок - 2.4 Проверка группы:
docker compose --profile bench config --quiet,make student-test -k "timeouts or drain"
3. Нагрузка и зонд
- 3.1
infra/k6/messages.js,scripts/k6.sh(запуск от uid хоста) - 3.2
scripts/probe.py:load(k6 + зонд + опрос LB,action.log, счётчики повторов LB,--expect dip|replace,pass),detect(действие фоном,--max,--until,--within-action,--lb-status,--restore),check --rounds - 3.3 Проверка группы:
make lint,make check(разборscripts/*.pyинтерпретатором CI),k6 inspect
4. Сценарии уровня «4»
- 4.1
scripts/detection.shиmake detection:SIGTERM,docker kill,docker pause, остановка PostgreSQL с заявленными максимумами - 4.2
scripts/failover-each.shиmake failover-each: остановка, 10 с без реплики и возврат каждой реплики под нагрузкой - 4.3
scripts/limits.pyиmake limits: политика лимитов, портов, секретов, volumes, сетей - 4.4
scripts/rolling-update.shиmake rolling-update [FROM_REV=…]:migrateодин раз, замена с запасом +1, журнал образов - 4.5 Тест отказа PostgreSQL через LB: ответы
503, live внутри реплики200, LB исключает все реплики и сам отвечает503 - 4.6 CI:
make limits,make detectionв acceptance - 4.7 Проверка группы:
make up,make limits,make lb-check,make detection,make failover-each,make rolling-update FROM_REV=8d28d45,make test-faults
5. Отчёт
- 5.1
evidence/: detection, failover-each, rolling, limits, lb-check, повторные прогоны уровня «3» на новом коде - 5.2
REPORT.md: таймауты и обнаружение, строки 4.1–4.4, таблица отказов уровня «4», ограничения - 5.3 Проверка группы:
make check,make validate,make lint,make student-test,make test,make test-persistence ACTION_SCRIPT=scripts/restart.sh,make test-failover ACTION_SCRIPT=scripts/stop-one.shдля обеих реплик