forked from mtusi2026/mtusi2026lab2
The first failover-each run had no errors, yet the balancer counted 19 and 49 redispatches. The HAProxy log showed why: when a stopped container comes back into Docker DNS, its server-template slot leaves MAINT (resolution) as UP/READY at once, before any health check, so requests went to a gunicorn that was not listening yet and were redispatched to the other replica. default-server now sets init-state fully-down (HAProxy 3.1+): at start, on discovery through DNS and on leaving maintenance a server stays DOWN until rise 2 checks pass. A rerun under 100 rps shows zero retries and redispatches for both replicas; rejoining takes about a second longer. The design and the failover spec of the change record the finding. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>