Forum: NGINX Balancer Algorithms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Stephen Nelson-Smith (Guest)
on 2008-11-20 13:21
(Received via mailing list)
Hello,

I want to distribute traffic across backend servers based purely on
*availability*.

I don't want to send some traffic to one which is less busy, or has
less traffic, , or has fewer connections, I want to send traffic to a
second node only if the first node is unavailable.

How can I do this?

S.
Almir K. (Guest)
on 2008-11-20 13:36
(Received via mailing list)
On Thu, Nov 20, 2008 at 11:09:08AM +0000, Stephen Nelson-Smith wrote:
> Hello,
>
> I want to distribute traffic across backend servers based purely on
> *availability*.
>
> I don't want to send some traffic to one which is less busy, or has
> less traffic, , or has fewer connections, I want to send traffic to a
> second node only if the first node is unavailable.
>
> How can I do this?

see http://wiki.codemongers.com/NginxHttpUpstreamModule , you are
looking for
the "backup" argument.
Philipp Michels (Guest)
on 2008-11-20 13:39
(Received via mailing list)
Stephen Nelson-Smith schrieb:
>
> S.
>

take a look at http://wiki.codemongers.com/NginxHttpUpstreamModule

the section "server" describes some options, e.g.

--snip--

backup - (0.6.7 or later) only uses this server if the non-backup
servers are all down or busy

--snap--

so this should work:

upstream  backend  {
    server   backend1.example.com;
    server   backend2.example.com backup;
}

kind regards

Philipp

--

*** ACHTUNG: Meine Telefonnummer hat sich geƤndert: 203 - 4669 ***

Dipl.-Inf. Philipp Michels
Rechenzentrum Universitaet Freiburg
Stefan-Meier-Str. 31a, 79104 Freiburg
Tel: 0761/203-4669, Fax: 0761/203-4643
E-Mail: removed_email_address@domain.invalid

PGP-Key: http://omnibus.ruf.uni-freiburg.de/~michels/pubkey.asc
PGP-Fingerprint: 4212 96E7 351E C00D 5506 5B59 EEEE CA1A 9D25 137E
Stephen Nelson-Smith (Guest)
on 2008-11-20 14:15
(Received via mailing list)
Hi,
> so this should work:
>
> upstream  backend  {
>    server   backend1.example.com;
>    server   backend2.example.com backup;
> }

That looks good.  If I add backend3.example.com backup, I assume that
is used only if backed2 fails.

S.
Grzegorz N. (Guest)
on 2008-11-20 14:23
(Received via mailing list)
On Thu, Nov 20, 2008 at 12:08:05PM +0000, Stephen Nelson-Smith wrote:
> Hi,
> > so this should work:
> >
> > upstream  backend  {
> >    server   backend1.example.com;
> >    server   backend2.example.com backup;
> > }
>
> That looks good.  If I add backend3.example.com backup, I assume that
> is used only if backed2 fails.

No, not really (AFAIK). There are two sets of backends: normal and
backup ones. When all normal backends fail, Nginx switches to the backup
set and vice versa.

Oh, and backup backends probably don't work at all with upstream_fair
(never tested, left as a TODO in source).

Best regards,
 Grzegorz N.
Maxim D. (Guest)
on 2008-11-20 14:24
(Received via mailing list)
Hello!

On Thu, Nov 20, 2008 at 12:08:05PM +0000, Stephen Nelson-Smith wrote:

> Hi,
> > so this should work:
> >
> > upstream  backend  {
> >    server   backend1.example.com;
> >    server   backend2.example.com backup;
> > }
>
> That looks good.  If I add backend3.example.com backup, I assume that
> is used only if backed2 fails.

No, your assumption is wrong.  All servers with backup flag are
activated if all servers without backup flag are dead.

Maxim D.
Stephen Nelson-Smith (Guest)
on 2008-11-20 14:29
(Received via mailing list)
Hi,

>> That looks good.  If I add backend3.example.com backup, I assume that
>> is used only if backed2 fails.
>
> No, your assumption is wrong.  All servers with backup flag are
> activated if all servers without backup flag are dead.

Ahh... So is there a way to do this:

* backend1 (primary)>
* if backend1 fails, send traffic to backend2
* if backend2 fails, send traffic to backend3

S.
Asif A. (Guest)
on 2008-11-20 14:56
(Received via mailing list)
Is this a good replacement instead of using Haproxy?

Asif A.
Cherife Li (Guest)
on 2008-11-20 16:25
(Received via mailing list)
On Thu, 20 Nov, 2008 at 18:20:25 +0530, Asif A. wrote:

> Is this a good replacement instead of using Haproxy?
I'm afraid not.
HAProxy is specially designed for TCP and HTTP-based applications. It
has more functionalities.
Anyway, it depends on your demands. Maybe we need some comparison
between the two in production environment.
This topic is locked and can not be replied to.