docker-archive / dockercloud-haproxy

HAproxy image that autoreconfigures itself when used in Docker Cloud
https://cloud.docker.com/
651 stars 187 forks source link

Retry Policy #193

Closed ghost closed 6 years ago

ghost commented 7 years ago

Is there any possibility to configure a retry policy for HAProxy? For example if there are multiple instances of a backend service and one of these instances goes offline to which the next request will be routed, HAProxy should rather retrying the request with another instance than giving instantly an error.

tifayuki commented 7 years ago

@dschroe

There is health check settings on each backend server. If one of the server goes offline, haproxy will mark the route as a down status and will now dispatch the next request to it.

Before detecting a server offline, haproxy may still try to load balance on that server, and that request may get an error. There is no retry on the request, but you could config the health check to make haproxy detect the backend failure faster.

ghost commented 7 years ago

The healt check seems to be enabled by default: https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#5.2-check

So every request which is sent to an offline instance/route will not be handled because there is no retry policy which would reroute that request to another instance of the same service? How long does it take for the HAProxy to mark an offline service as a dead route per default? 30s?

tifayuki commented 7 years ago

By default, it is inter 2000 rise 2 fall 3, you can always use envvar HEALTH_CHECK to change the value. You can find more detailed explanation in HAProxy document

tifayuki commented 7 years ago

BTW, there is also a failover option(envvar FAILOVER) you can use, see http://blog.haproxy.com/2014/01/17/emulating-activepassing-application-clustering-with-haproxy/