Multiple upstream backup directives in stream module

Marcin Wanat marcin.wanat at gmail.com
Thu Sep 27 12:51:25 UTC 2018


 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.


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180927/53ae17fd/attachment.html>


More information about the nginx mailing list