ЛР3: балансировка HAProxy, 2 реплики API, идемпотентность, отказоустойчивость (на 4)

- X-Instance-Id в каждом ответе; обязательный Idempotency-Key, таблица idempotency_keys
  (миграция 0002, одна транзакция, конкурентные повторы через уникальный индекс)
- graceful shutdown: SIGTERM -> ready=503 -> drain 3 с -> закрытие порта
- compose: lb (HAProxy) + api x2 без портов + разовый migrate + postgres, лимиты CPU/RAM
- хуки stop-one/restart/restore-replicas, scripts/experiments.py (failover, idempotency, rolling)
- свои тесты: 44 (13 новых); evidence: smoke, pytest, persistence, failover, эксперименты
This commit is contained in:
2026-10-29 10:58:17 +03:00
parent 0ab3a341aa
commit cde3374d8a
74 changed files with 6231 additions and 25 deletions
+7
View File
@@ -0,0 +1,7 @@
# 2026-10-29T10:53:36
20 x GET /api/v1/users/me with ONE bearer token (no re-login) through LB:
X-Instance-Id 3de2fdb570eb -> 10 responses
X-Instance-Id 945116f913cc -> 10 responses
$ docker ps (api containers: short ID = hostname = X-Instance-Id; no published ports)
945116f913cc mtusi-lab3-api-5 Up 36 seconds (healthy) ports=8080/tcp
3de2fdb570eb mtusi-lab3-api-6 Up About a minute (healthy) ports=8080/tcp