2

I wonder whether there is a way to configure a default backend in haproxy, so it balances requests among a pool of backend servers (three in the example below), keeping the default backend as a failover, only in case the three main backends are down.

It should be something like this:

  server backend-0 10.10.10.0:3000 check
  server backend-1 10.10.10.1:3100 check
  server backend-2 10.10.10.2:3200 check
  server backend-default 10.10.10.3:3300 check

I have tried setting a weight 0 in the backend-default, but that completely removes the server from the balancing algorithm.

1 Answer 1

2

Kind of - it is called "backup":

server backend-default 10.10.10.3:3300 check inter 5000 rise 1 fall 3 backup

From the haproxy docs:

Since version 1.1.17, it is possible to specify backup servers. These servers are only sollicited when no other server is available. This may only be useful to serve a maintenance page, or define one active and one backup server (seldom used in TCP mode). To make a server a backup one, simply add the 'backup' option on its line. These servers also support cookies, so if a cookie is specified for a backup server, clients assigned to this server will stick to it even when the other ones come back. Conversely, if no cookie is assigned to such a server, the clients will get their cookies removed (empty cookie = removal), and will be balanced against other servers once they come back. Please note that there is no load-balancing among backup servers by default. If there are several backup servers, the second one will only be used when the first one dies, and so on. To force load-balancing between backup servers, specify the 'allbackups' option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .