forked from mtusi2026/mtusi2026lab4
58 lines
1.7 KiB
INI
58 lines
1.7 KiB
INI
# Single public entry point in front of the API replicas.
|
|
# Backends are discovered through Docker DNS (service name `api`) and receive traffic only while /health/ready is 200.
|
|
|
|
global
|
|
log stdout format raw local0 info
|
|
# Without it HAProxy sizes buffers from the file descriptor limit and uses ~100 MB.
|
|
maxconn 4096
|
|
|
|
defaults
|
|
mode http
|
|
log global
|
|
option httplog
|
|
option dontlognull
|
|
option forwardfor
|
|
timeout connect 1s
|
|
timeout client 30s
|
|
timeout server 30s
|
|
timeout http-request 10s
|
|
timeout http-keep-alive 5s
|
|
# Retried only when the connection to a replica fails, i.e. before the request was sent:
|
|
# a POST that reached a replica is never repeated by the balancer.
|
|
retries 2
|
|
option redispatch 1
|
|
|
|
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
|
|
accepted_payload_size 8192
|
|
|
|
frontend http
|
|
bind :8080
|
|
default_backend api
|
|
|
|
# Not published: container healthcheck and the backend table (wget -qO- "http://127.0.0.1:8404/stats;csv").
|
|
frontend internal
|
|
bind :8404
|
|
monitor-uri /healthz
|
|
stats enable
|
|
stats uri /stats
|
|
stats refresh 5s
|
|
|
|
backend api
|
|
balance roundrobin
|
|
option httpchk GET /health/ready
|
|
http-check expect status 200
|
|
# A replica leaves rotation after 2 failed checks 1 s apart and returns after 2 successful ones.
|
|
default-server check inter 1s fall 2 rise 2 resolvers docker init-addr none
|
|
# Up to 4 replicas; slots without a resolved address stay in maintenance.
|
|
server-template api 4 api:8080
|