Welcome! Log In Create A New Profile

Advanced

Re: Multiple upstream backup directives in stream module

Roman Arutyunyan
September 27, 2018 12:58PM
Hi,

On Thu, Sep 27, 2018 at 02:51:25PM +0200, Marcin Wanat wrote:
> Hi,
>
> i am using latest (1.15.4) nginx with stream module.
>
> I am trying to create config with one primary server that will accept no
> more than 10 connections and multiple backups that will also receive up to
> 10 connections only when previous backup server is already full.
>
> As exact behavior of multiple backup directives is not well explained in
> documentation i would like to ask if i am doing right.

There's only one level of upstream backup in nginx. Once all primary servers
fail, the balancer switches to backup servers. All backup servers are equal.
One of them is chosen based on the balancing algorithm. If it fails, another
one is chosen and so on, just like it happens with primary servers.

If you want several levels of backup, you still can do it with 'error_page 502'.
Once all servers in your initial location fail (primary + 1st level backup),
error 502 is generated. Then you continue in another location specified in
error_page and repeat proxying with other servers (2nd level backup).

> My current configuration is:
> stream {
> upstream backend {
> zone upstream_backend 64k;
> server 10.0.1.1:9306 max_conns=10;
> server 10.0.1.2:9306 max_conns=10 backup;
> server 10.0.1.3:9306 max_conns=10 backup;
> server 10.0.1.4:9306 backup;
> }
> server {
> listen 127.0.0.1:9306;
> proxy_connect_timeout 1s;
> proxy_timeout 3s;
> proxy_pass backend;
> }
> }
>
>
> I would like it to work like this:
>
> When we have up to 10 concurrent connections, all should go always to
> primary 10.0.1.1
>
> When we have 25 concurrent connections it should work like this:
> -First 10 connections go to primary 10.0.1.1
> -Next 10 connections go to backup 10.0.1.2
> -Next 5 connections go to backup 10.0.1.3
>
> When we have 45 concurrent connections it should work like this:
> -First 10 connections go to primary 10.0.1.1
> -Next 10 connections go to backup 10.0.1.2
> -Next 10 connections go to backup 10.0.1.3
> -Next 15 connections go to backup 10.0.1.4
>
>
> Will multiple backup directives work as i expected or will they just round
> robin between each of them up to max_conns limit ?
>
>
> Regards,
> Marcin Wanat

> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


--
Roman Arutyunyan
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Multiple upstream backup directives in stream module

Marcin Wanat September 27, 2018 08:54AM

Re: Multiple upstream backup directives in stream module

Roman Arutyunyan September 27, 2018 12:58PM

Re: Multiple upstream backup directives in stream module

Roman Arutyunyan September 28, 2018 11:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 125
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready