forked from mtusi2026/mtusi2026lab3
Лаба 3: Nginx LB, 2 реплики API и общая идемпотентность (оценка 4)
Переиспользован стек lab2 (Postgres/Redis/Argon2id). Добавлены: Nginx балансировщик перед api1/api2, общая идемпотентность POST-сообщений (idempotency_keys + advisory-lock сериализация в Postgres), explicit stop-one/restart hooks. make test/test-persistence/test-failover/validate зелёные для обеих реплик; найдены и исправлены гонка миграций и гонка рестарта Nginx/DNS — см. REPORT.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
worker_processes 1;
|
||||
# A single worker keeps the round-robin counter shared and deterministic for
|
||||
# the lab's small replica count; a production LB would instead rely on a
|
||||
# shared/consistent balancing policy across workers.
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
upstream messenger_api {
|
||||
# Passive health check: a backend failing 1 probe is removed for 3s,
|
||||
# which keeps failover detection well under the 10s budget.
|
||||
server api1:8080 max_fails=1 fail_timeout=3s;
|
||||
server api2:8080 max_fails=1 fail_timeout=3s;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
location / {
|
||||
proxy_pass http://messenger_api;
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_read_timeout 5s;
|
||||
proxy_next_upstream error timeout http_502 http_503 http_504;
|
||||
proxy_next_upstream_tries 2;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user