chore: carry lab 3 over

- carry the lab 3 solution over from mtusi2026lab3-safronov
  (solution/bvt2301-safronov, ce89eba): src, migrations, student-tests,
  bench, openspec, .claude, infra/haproxy and infra/valkey, own scripts,
  Dockerfile, compose, pyproject and uv lock
- merge Makefile, .gitignore and .dockerignore (the lab 3 versions only
  add lines to the skeleton, which is the same in lab 4) and
  .env.example (lab 4 skeleton names listed in the header)
- rename the compose project to mtusi-lab4 and the image to :lab4 so
  the stand does not reuse the lab 3 containers and volumes
- update AGENTS.md for lab 4: current lab, origin commit, contract and
  test files of the new skeleton

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 17:32:33 +03:00
co-authored by Claude Opus 5.5
parent ec540a1a72
commit 5d5d8f9d2a
365 changed files with 64878 additions and 19 deletions
+90
View File
@@ -0,0 +1,90 @@
# Override стенда make bench (bench/run.py): тот же docker-compose.yml под
# проектом mtusi-bench, со своими volume, сетью и лимитами. Пины, healthcheck
# хранилищ, valkey.conf, haproxy.cfg и миграции — из основного файла.
# Подстановки — из bench/bench.env, а не из .env рабочего стенда; пароли и
# BENCH_* передаёт run.py (поля Profile), без них стенд не поднимается.
# Решения 1, 2, 5 design change bench-postgres и 6 design change
# graceful-failover; что не меняется между метками — .claude/rules/bench.md.
# Стенд — HAProxy перед BENCH_API_REPLICAS репликами api, как рабочий; k6
# ходит через LB по имени сервиса haproxy. Лимиты — в форме
# deploy.resources.limits, как в основном файле: compose не принимает
# cpus/mem_limit рядом с deploy-лимитами.
services:
postgres:
container_name: mtusi-bench-postgres
# упавший контейнер не поднимается сам: прогон помечается stand_down
restart: "no"
# auto_explain загружен, но выключен (log_min_duration = -1): run.py
# включает его только на этапе плана, между прогонами. max_connections
# — конфигурация серии трека 1 (граница пула), у прочих профилей 100,
# как у образа (решение 1 design change scaling-bench)
command:
- postgres
- -c
- shared_preload_libraries=auto_explain
- -c
- max_connections=${BENCH_DB_MAX_CONNECTIONS:?run make bench}
ports: !reset []
deploy:
resources:
limits:
cpus: ${BENCH_DB_CPUS:?run make bench}
memory: ${BENCH_DB_MEMORY:?run make bench}
memswap_limit: ${BENCH_DB_MEMORY:?run make bench}
valkey:
container_name: mtusi-bench-valkey
restart: "no"
ports: !reset []
deploy:
resources:
limits:
cpus: ${BENCH_CACHE_CPUS:?run make bench}
memory: ${BENCH_CACHE_MEMORY:?run make bench}
memswap_limit: ${BENCH_CACHE_MEMORY:?run make bench}
migrate:
image: mtusi-messenger:bench
# без config.toml рабочего стенда: настройки — окружение и дефолты
volumes: !reset []
api:
# реплики без постоянного имени (оно мешало бы масштабированию):
# оркестратор находит их через docker compose ps, k6 ходит через LB
image: mtusi-messenger:bench
restart: "no"
volumes: !reset []
# healthcheck образа — лишний CPU внутри лимита API; готовность реплик
# проверяет HAProxy (раз в секунду /health/ready)
healthcheck:
disable: true
environment:
# размер 500k с наполнением идёт ~25 мин; на медленном хосте срок
# 3600 с по умолчанию мог бы истечь посреди прогона и дать 401
AUTH__SESSION_TTL_SECONDS: ${BENCH_SESSION_TTL_SECONDS:?run make bench}
deploy:
replicas: ${BENCH_API_REPLICAS:?run make bench}
resources:
limits:
# на каждую реплику
cpus: ${BENCH_APP_CPUS:?run make bench}
memory: ${BENCH_APP_MEMORY:?run make bench}
memswap_limit: ${BENCH_APP_MEMORY:?run make bench}
haproxy:
# один экземпляр: имя нужно оркестратору (статистика, журнал)
container_name: mtusi-bench-haproxy
restart: "no"
# порт рабочего стенда не занимает: k6 в сети стенда
ports: !reset []
deploy:
resources:
limits:
cpus: ${BENCH_LB_CPUS:?run make bench}
memory: ${BENCH_LB_MEMORY:?run make bench}
memswap_limit: ${BENCH_LB_MEMORY:?run make bench}
networks:
default:
# k6 подключается к сети стенда по имени (docker run --network)
name: mtusi-bench