But if the backend just vanishes, there is not indication for haproxy to react, all you have are timeouts (and this should only happen with a catastrophic HW failure; if you are specifically killing a container instead of properly shutting it down, that leads to the same behaviour as a catastrophic HW failure I guess).
So instead of restarting the container, I’m trying to stop it gracefully:
docker compose exec franken frankenphp stop
With the health check configured, HAProxy marks it down as expected:
haproxy-1 | Server franken/franken1 is DOWN, reason: Layer7 timeout, check duration: 2003ms. 0 active and 0 backup servers left. 1 sessions active, 0 requeued, 0 remaining in queue.
haproxy-1 | backend franken has no server available!
haproxy-1 | [WARNING] (8) : Server franken/franken1 is DOWN, reason: Layer7 timeout, check duration: 2003ms. 0 active and 0 backup servers left. 1 sessions active, 0 requeued, 0 remaining in queue.
haproxy-1 | [ALERT] (8) : backend ‘franken’ has no server available!
Capturing the front and backend traffic while this happens and taking a look at it would be most helpful.
Depending on how you come to this conclusion, the client may receive the error but keep on pushing data. Taking a look at what happens on the wire would be most helpful.
Turned out the issue was on the file upload JavaScript library. I didn’t expect that.
Using curl, the connection was closed as expected, and changing the file upload library resolved the issue and a proper error is shown to the client.
Thanks for your help! It allowed me to understand better HAProxy, and optimize my configuration.