Using round robin for load balancing if hash key is empty
Roman Arutyunyan
arut at nginx.com
Mon May 27 16:59:43 UTC 2019
Hello Niklas,
On Thu, May 23, 2019 at 07:54:46PM +0200, Niklas Keller wrote:
> > > I'd like to propose falling back to round robin if the hash key is
> > > empty. This allows using hashed cookie values for sticky sessions
> > > while using round robin for all requests that do not carry any session
> > > information and thus do not need the stickiness. While Nginx Plus
> > > allows to use the learning mode, this patch avoids the need for
> > > synchronization between multiple instances.
> > >
> >
> > Can you please elaborate on balancing/sticky scheme you are using?
> >
> > Say, first request without cookie is balanced by round-robin, arrives
> > at some backend, which responds with cookie.
> > Next time, the request with cookie is balanced by hash algorithm,
> > and the result can be easily another backend. How do you deal with this?
>
> Very few requests depend on the stickiness in our application. The
> main use case is showing success messages once after a form is
> submitted.
>
> In these cases, the usual flow is:
> - GET /form → Server assigns cookie
> - POST /form → Client sends cookie, a different server might be
> selected, but doesn't matter
> - GET /form?_key=abc → Client sends cookie again, success message is
> shown and removed from the session, same server as in the previous
> request is selected
>
> For cookie-less clients, e.g. crawlers and webhooks, the stickiness
> doesn't matter at all, so these shouldn't be sticky to avoid peaks on
> single backend nodes.
>
> @Roman: Patch looks good to me, thanks!
Committed, thanks.
https://hg.nginx.org/nginx/rev/d964b0aee8e7
--
Roman Arutyunyan
More information about the nginx-devel
mailing list