How to mark Haproxy server initially down

haproxy

I have an haproxy.cfg that is dynamically updated when new servers are added, however at the time a new server is added the server may still be coming up. (Servers are not initially healthy). Due to this, I receive some 50x errors when new servers are introduced.

I have little control of this timing, but I have some control over the params that are set on the server and backend.

Is there a way that I can set params on a server or a backend such that a new server will not take traffic until it is healthy?

This is an example of my current backends:

backend my_backend
  balance roundrobin
  mode http
  option  httpchk GET /actuator/health
  timeout check 5s
  server 10_48_111_20_31623 10.48.111.20:31623 check inter 10s fall 4
  server 10_48_111_55_31430 10.48.111.55:31430 check inter 10s fall 4
  server 10_48_111_55_31479 10.48.111.55:31479 check inter 10s fall 4 

Best Answer

Best way how to achieve this is via admin socket of haproxy. When new configuration is reloaded, you can send haproxy command to mark server as offline. See http://cbonte.github.io/haproxy-dconv/1.7/management.html#9.3 for more information about using admin socket.