Files
mtusi2026lab3/infra/haproxy/haproxy.cfg
T
Mlvn b1972bcfd8 Реализовать lab3: HAProxy, API×N, идемпотентность и трек 1.
Горизонтальное масштабирование за LB с общими сессиями Redis, X-Instance-Id,
обязательным Idempotency-Key в PostgreSQL, сценариями failover/persistence и
измерением цены масштабирования при фиксированном CPU/RAM бюджете.
2026-11-06 21:07:00 +03:00

53 lines
1.7 KiB
INI
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HAProxy — единственная публичная точка входа lab3.
#
# Backend-адреса берутся из Docker DNS имени сервиса `api` (A-записи всех реплик).
# server-template + resolvers перечитывает DNS; option httpchk снимает реплику,
# у которой /health/ready != 200 (в т.ч. после BeginDrain на SIGTERM).
#
# Оценка обнаружения отказа:
# inter 1s * fall 2 = ~2s по healthcheck + hold valid 2s у DNS ≈ до ~4s.
# Краткие 502/503 в это окно допустимы контрактом failover-теста.
global
log stdout format raw local0
maxconn 512
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 2s
timeout client 15s
timeout server 15s
timeout check 1s
timeout http-keep-alive 10s
retries 2
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 2s
hold other 2s
hold refused 2s
hold nx 2s
hold timeout 2s
hold obsolete 2s
frontend fe_http
bind *:8080
default_backend be_api
backend be_api
balance roundrobin
option httpchk
option redispatch
retry-on conn-failure empty-response response-timeout
http-check send meth GET uri /health/ready
http-check expect status 200
# До 8 слотов под --scale api=N. init-addr last,libc,none ждёт DNS при старте.
# fall 3: чуть терпимее к краткому DNS-мерцанию при docker stop одной реплики.
server-template api 8 api:8080 check inter 1s fall 3 rise 1 resolvers docker resolve-prefer ipv4 init-addr last,libc,none