3

I have a HAProxy configuration with a single backend something very similar to this:

backend mybackend
option httpchk get /ping
http-check expect ! rstatus ^5
server mybackend-0 192.168.1.1:9041 weight 1

The /ping endpoint always return 200.

My question: Is there any advantage of doing a health check on a single server? As I understand health check only makes sense when we have multiple backend servers and you want to load balance them.

Any help in this regard will be appreciated.

Thanks

3

It makes sense to healthcheck a single server to allow for a 'circuit breaker' scenario. Imagine your backend is accepting TCP connections but is unable to generate a response. Client apps connecting through this haproxy will have to wait until their built-in timeout occurs to close the connection. If they are usually expecting a 50ms response time, and now have to wait 3s for their request-timeout to expire, they are most likely going to fail.

A very well written client app will detect this situation and perform their own circuit breaking, but in my experience most apps do not. Adding the healthcheck to HAProxy lets HAProxy circuit-break on their behalf.

So, the backend is unable to generate a response and causes the healthcheck to fail. HAProxy then immediately responds to any incoming requests with a well-formed 503, and the client app can then deal with that however it likes.

Much of the time applications are written assuming that backends quickly reply with a success or failure. Having HAProxy do the health checks mitigates some of the scenarios where the application doesn't handle a non-response.

  • In my settings that single server is actually a load balancer itself. I want to have a nice frontend mapping from my clients to the server. That load balancer has its own health checks and exactly knows which servers are working and which are not and handles the responses appropriately. – Zeeshan Dec 16 '16 at 20:56

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.