Upstream get stuck in disabled state for websocket load balancing

Maxim Dounin mdounin at
Mon Jul 12 01:28:49 UTC 2021


On Fri, Jul 09, 2021 at 09:13:37AM -0400, Oleg Pisklov wrote:


> Then a strange thing happens. I expect that new websocket connections will
> be distributed evenly among two backends. But most of them land on backend1,
> as if backend2 is still disabled. Sometimes there is one client that
> connects to backend2, but it's the only one.
> Further attempts to close connections on server side show the same picture.
> I found that setting max_fails=0 solves the problem with distribution.
> Is this correct behavior? If so, how to assure proper distribution of
> websocket connection while using max_fails in such scenarios? Is there any
> documentation for it?

Quoting nginx 1.1.6 changes:

    *) Change: if a server in an upstream failed, only one request will be
       sent to it after fail_timeout; the server will be considered alive if
       it will successfully respond to the request.

That is, only one request (a websocket connection in your case) 
after fail_timeout to the failed backend is an expected behaviour.  
Once this connection is successfully closed, nginx will mark this 
backend as working properly and will start balancing new 
connections to the backend.

Maxim Dounin

More information about the nginx mailing list