ЛР 3 — БВТ2304 — Черников

HAProxy перед двумя репликами API, X-Instance-Id, общая идемпотентность отправки
сообщения в PostgreSQL, двухшаговая остановка реплики по SIGTERM, лимиты CPU/RAM,
хуки stop-one и restart. Проверки отказов, эксперимент и поочерёдное обновление
в scripts/lab3_checks.py, отчёт в REPORT.md, результаты в evidence/, команды для
показа в DEMO.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 18:08:30 +03:00
co-authored by Claude Opus 5.5
parent 0ab3a341aa
commit 54ee33352d
48 changed files with 4967 additions and 24 deletions
+16 -9
View File
@@ -1,13 +1,20 @@
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
# These are logical interface suggestions; map actual framework names in REPORT.md.
APP_HOST=0.0.0.0
APP_PORT=8080
# docker compose reads .env to fill ${...} in compose.yaml; every value has a default there.
# Passwords are NOT here: they are files in secrets/ (python scripts/init_secrets.py).
APP_ENV=lab
SESSION_TTL_SECONDS=3600
# Choose credentials locally. File paths contain no secret values.
DATABASE_URL_FILE=/run/secrets/database_url
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
SESSION_STORE=postgres
CACHE_URL_FILE=/run/secrets/cache_url
APP_LOG_LEVEL=INFO
# Seconds for graceful stop after SIGTERM (<= 10) and, inside it, how long a replica keeps
# serving while reporting "not ready" so that the load balancer removes it first.
APP_SHUTDOWN_TIMEOUT=8
APP_DRAIN_DELAY=3
# Load balancer ports on 127.0.0.1 of the host (API replicas are not published).
APP_PUBLISHED_PORT=8080
LB_STATS_PORT=8404
API_REPLICAS=2
SESSION_TTL_SECONDS=3600
IDEMPOTENCY_TTL_SECONDS=86400
DB_POOL_SIZE=10
# Fixed inside the containers by compose.yaml (skeleton names kept):
# APP_HOST=0.0.0.0 APP_PORT=8080
# DATABASE_URL_FILE=/run/secrets/database_url CACHE_URL_FILE=/run/secrets/cache_url
# SESSION_STORE from the skeleton is not needed: sessions are always stored in Valkey.