Reverse proxy: load balance between two servers with third server as backup

Is it possible to enable load balancing between two servers with a third server as a backup?

Something like lb_policy round_robin but with N number of upstream.
For example, it would be great to specify the first two upstreams, then use the last one when the first two upstreams are unavailable: lb_policy round_robin 2.

In our case, we have a third server as a backup, but the processing power of this server is worse than the first two production-grade servers. We want to load balance between the first two servers to ensure the best performance.

Example config

reverse_proxy node1 node2 node3 {
  lb_policy round_robin
1 Like

Hmm. Good question. That is tricky. Not something we’ve considered before.

I think you could do it like this, kinda awkward though: {
	reverse_proxy node1 node2 {
		lb_policy round_robin
		# make sure you have health checks enabled
		# otherwise the nodes will never be marked unhealthy

	handle_errors {
		@proxyErr `{err.status_code} in [502, 503]`
		reverse_proxy @proxyErr node3

If all the upstreams are unavailable (503) or failed to connect (502) then it will proxy to node3.

1 Like

Thank you! I wish it was more elegant though :smiley:

Haha I love this, it’s brilliant! :slight_smile: