Jason
Jason

Reputation: 3

HAProxy basic configuration - defining primary backend

Quite a simple question - looking to use HA Proxy to solve an issue with accessing primary or secondary servers. The ideal is a system where the proxy always directs users to the Primary unless 1: the primary is not responding on a specified port or 2: We tell the proxy to use the secondary Would this be a case of using Round Robin with Weighting and assigning a maximum weight of 256 (?) to primary and a weight of 1 to secondary? So in this case if Primary is inaccessible then secondary is used ? And to tell the system which to use then we can simply swap the weighting or similar?

Thanks

Upvotes: 0

Views: 1099

Answers (1)

mwp
mwp

Reputation: 8467

Easy answer! In your backend definition(s), you can mark server(s) as "backup", and HAProxy will only route requests to those server(s) if the non-backup server(s) are not available. From the configuration manual:

When "backup" is present on a server line, the server is only used in load balancing when all other non-backup servers are unavailable. Requests coming with a persistence cookie referencing the server will always be served though. By default, only the first operational backup server is used, unless the "allbackups" option is set in the backend. See also the "allbackups" option.

Upvotes: 1

Related Questions