Welcome! Log In Create A New Profile

Advanced

Behavior between upstream hash and backup

Posted by Jonathan Simowitz via nginx 
Jonathan Simowitz via nginx
Behavior between upstream hash and backup
January 11, 2017 10:30PM
Hello,

I would like to define an upstream block with a number of servers and
utilize the hash directive to choose a particular server dependent on the
request. There is a chance that the chosen server could fail and so I would
also like to configure a backup server to handle the request in this case.
If I define an additional server in this upstream and declare it as backup
will it handle the request if the hash-chosen server fails as defined by my
proxy_next_upstream directive?

If so, great! If not, what is the recommended way to achieve this desired
behavior?

Thank you,
~Jonathan

--
Jonathan Simowitz | Jigsaw | Software Engineer | simowitz@google.com |
631-223-8608
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Robert Paprocki
Re: Behavior between upstream hash and backup
January 11, 2017 10:40PM
Hi,

On Wed, Jan 11, 2017 at 1:27 PM, Jonathan Simowitz via nginx <
[email protected]> wrote:

> Hello,
>
> I would like to define an upstream block with a number of servers and
> utilize the hash directive to choose a particular server dependent on the
> request. There is a chance that the chosen server could fail and so I would
> also like to configure a backup server to handle the request in this case.
> If I define an additional server in this upstream and declare it as backup
> will it handle the request if the hash-chosen server fails as defined by my
> proxy_next_upstream directive?
>

Have you had a look at the 'backup' parameter of
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#server? Sounds
like exactly what you need.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Jonathan Simowitz via nginx
Re: Behavior between upstream hash and backup
January 11, 2017 10:40PM
Hi Robert,

Thank you for your reply. Yes, I have taken the backup parameter into
account. It is not clear to me how the backup parameter works in
combination with the hash directive and whether this achieves the desired
behavior.

~Jonathan

On Wed, Jan 11, 2017 at 4:34 PM, Robert Paprocki <
[email protected]> wrote:

> Hi,
>
> On Wed, Jan 11, 2017 at 1:27 PM, Jonathan Simowitz via nginx <
> [email protected]> wrote:
>
>> Hello,
>>
>> I would like to define an upstream block with a number of servers and
>> utilize the hash directive to choose a particular server dependent on the
>> request. There is a chance that the chosen server could fail and so I would
>> also like to configure a backup server to handle the request in this case.
>> If I define an additional server in this upstream and declare it as backup
>> will it handle the request if the hash-chosen server fails as defined by my
>> proxy_next_upstream directive?
>>
>
> Have you had a look at the 'backup' parameter of http://nginx.org/en/docs/
> http/ngx_http_upstream_module.html#server? Sounds like exactly what you
> need.
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



--
Jonathan Simowitz | Jigsaw | Software Engineer | simowitz@google.com |
631-223-8608
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Behavior between upstream hash and backup
January 12, 2017 03:50PM
Hello!

On Wed, Jan 11, 2017 at 04:27:51PM -0500, Jonathan Simowitz via nginx wrote:

> Hello,
>
> I would like to define an upstream block with a number of servers and
> utilize the hash directive to choose a particular server dependent on the
> request. There is a chance that the chosen server could fail and so I would
> also like to configure a backup server to handle the request in this case.

If there are more than one server in the upstream block, the
default behaviour is to try another server if a choosen one fails,
see http://nginx.org/r/proxy_next_upstream. The exact algorithm
to select "another server" varies depending on the balancing
algorithm used - e.g., in case of "hash .. consistent" it means
selecting the next point in the continuum, like if the failed
server was removed from the list.

> If I define an additional server in this upstream and declare it as backup
> will it handle the request if the hash-chosen server fails as defined by my
> proxy_next_upstream directive?

No, backup servers are not supported by the hash balancer.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Jonathan Simowitz via nginx
Re: Behavior between upstream hash and backup
January 12, 2017 04:10PM
Thank you Maxim; that is exactly the detailed response I was looking for.
If possible I would recommend updating the docs to clarify this for others.
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash

~Jonathan

On Thu, Jan 12, 2017 at 9:44 AM, Maxim Dounin <[email protected]> wrote:

> Hello!
>
> On Wed, Jan 11, 2017 at 04:27:51PM -0500, Jonathan Simowitz via nginx
> wrote:
>
> > Hello,
> >
> > I would like to define an upstream block with a number of servers and
> > utilize the hash directive to choose a particular server dependent on the
> > request. There is a chance that the chosen server could fail and so I
> would
> > also like to configure a backup server to handle the request in this
> case.
>
> If there are more than one server in the upstream block, the
> default behaviour is to try another server if a choosen one fails,
> see http://nginx.org/r/proxy_next_upstream. The exact algorithm
> to select "another server" varies depending on the balancing
> algorithm used - e.g., in case of "hash .. consistent" it means
> selecting the next point in the continuum, like if the failed
> server was removed from the list.
>
> > If I define an additional server in this upstream and declare it as
> backup
> > will it handle the request if the hash-chosen server fails as defined by
> my
> > proxy_next_upstream directive?
>
> No, backup servers are not supported by the hash balancer.
>
> --
> Maxim Dounin
> http://nginx.org/
>



--
Jonathan Simowitz | Jigsaw | Software Engineer | simowitz@google.com |
631-223-8608
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login