Files
mtusi2026lab3/infra/haproxy.cfg
T
vika 59f8c55f93 Поставить несколько реплик API за общий балансировщик.
Сессия и ключ идемпотентности общие для реплик, миграция выполняется один раз, остановка одной реплики не теряет подтверждённые сообщения.
2026-10-30 01:15:28 +03:00

55 lines
1.6 KiB
INI

global
maxconn 256
defaults
mode http
timeout connect 500ms
timeout client 15s
timeout server 10s
timeout http-request 10s
timeout http-keep-alive 2s
timeout check 1s
timeout queue 1s
retries 1
option redispatch
option dontlognull
resolvers docker
nameserver dns 127.0.0.11:53
accepted_payload_size 8192
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 1s
hold other 1s
hold refused 1s
hold nx 1s
hold timeout 1s
frontend web
bind *:8080
acl message_post method POST
acl message_path path_reg ^/api/v1/chats/[0-9A-Fa-f-]{36}/messages$
use_backend api_messages if message_post message_path
default_backend api
backend api
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr host api
http-check expect status 200
# 503 is returned before a commit. A lost 201 is not retried: that would duplicate chats.
retry-on conn-failure 503
default-server on-marked-down shutdown-sessions
server-template api- 8 api:8080 check resolvers docker init-addr none inter 1s fall 2 rise 1 resolve-prefer ipv4
backend api_messages
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr host api
http-check expect status 200
# Message POST is safe to repeat: the idempotency key is shared by every replica.
retry-on conn-failure empty-response 502 503
default-server on-marked-down shutdown-sessions
server-template api- 8 api:8080 check resolvers docker init-addr none inter 1s fall 2 rise 1 resolve-prefer ipv4