# HAProxy for DIDI PostgreSQL HA — routes by Patroni REST health checks. # Mirrors the production LB config (10.11.50.166/169 → VIP 167). # # :5000 → the ONE node whose Patroni answers 200 on /primary (leader, RW) # :5001 → nodes answering 200 on /replica (round-robin, RO) # # On failover Patroni flips the health endpoints; HAProxy reroutes in # (inter × fall) ≈ 9s worst case without client config changes. global maxconn 300 log stdout format raw local0 defaults log global mode tcp retries 2 timeout client 30m timeout connect 4s timeout server 30m timeout check 5s listen stats mode http bind *:7000 stats enable stats uri / listen postgres_write bind *:5000 option httpchk GET /primary http-check expect status 200 default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions server pg-node1 pg-node1:5432 check port 8008 server pg-node2 pg-node2:5432 check port 8008 server pg-node3 pg-node3:5432 check port 8008 listen postgres_read bind *:5001 balance roundrobin option httpchk GET /replica http-check expect status 200 default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions server pg-node1 pg-node1:5432 check port 8008 server pg-node2 pg-node2:5432 check port 8008 server pg-node3 pg-node3:5432 check port 8008