Re: Question about TCP balancing

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 5 Aug 2009 06:30:39 +0200


Hi,

On Tue, Aug 04, 2009 at 11:18:25AM +0400, Dmitry Sivachenko wrote:
> Hello!
>
> Thanks for clarification.
>
> I have another question then (trying to solve my problem in a different way).
>
> I want to setup the following configuration.
> I have 2 sets of servers (backends): let call one set NEAR (n1, n2, n3)
> and another set FAR (f1, f2, f3).
>
> I want to spread incoming requests between NEAR servers only
> when they are alive, and move load to FAR servers in case NEAR set is down.
>
> Is it possible to setup such configuration?

By default you can do that with the backup servers, by enabling the "allbackups" option :

backend my_servers

	balance roundrobin
	option allbackups
	server near1 1.1.1.1 check
	server near2 1.1.1.2 check
	server near3 1.1.1.3 check
	server far1  2.1.1.1 check backup
	server far2  2.1.1.2 check backup
	server far3  2.1.1.3 check backup

It says that the load balancing will be performed across all backup servers once the normal servers will all be down.

If you want to use thresholds you can do that with two backends, for instance if you at least want 2 servers alive to deliver the service :

frontend my_front

	acl near_usable nbsrv(near) ge 2
	acl far_usable  nbsrv(far)  ge 2
	use_backend near if near_usable
	use_backend far  if far_usable
	# otherwise error

backend near
	balance roundrobin
	server near1 1.1.1.1 check
	server near2 1.1.1.2 check
	server near3 1.1.1.3 check

backend far
	balance roundrobin
	server far1  2.1.1.1 check
	server far2  2.1.1.2 check
	server far3  2.1.1.3 check

Just a warning though : the use_backend keyword can only be used with HTTP protocol in version 1.3. It's only in 1.4 that it becomes usable with any TCP protocol. So if you want to stay away from development versions, you'd better use the simple proposal with the backup servers.

Regards,
Willy Received on 2009/08/05 06:30

This archive was generated by hypermail 2.2.0 : 2009/08/05 06:45 CEST