0

We are using haproxy for loadbalancing across several machines. Our application includes a number of services, each deployed as an independent war in tomcat, that can be requested. Currently I have a single backend that get's loadbalanced to, which means if any one server starts returning errors the entire box will be considered 'bad' and removed from the load balancer.

so for example if box A were to start throwing bad responses when someone makes requests to https://myAwsomeApp/foo/ Then box A would be removed entirely from the load balancer, meaning that a request to https://myAwsomeApp/bar/ would never get routed to box A, even if that separate service was functional and could still support requests to it.

I want to change this so that each of the services are independent, so that even if the foo app goes down on box A then request to /bar will still be routed to A.

I know I could do this using ACl to cause requests to https://myAwsomeApp/foo to go to a difference backend then request to https://myAwsomeApp/bar; but that seems a little silly since the two backends would have the exact same hosts in them.

I also want a quick way to take an entire box down at once for when we deploy new code or have issues at specific sites, and having to modify 10 backends (one for each service the box supports) seems annoying and prone to errors where one backend is missed.

So is there a cleaner way to have my cake and eat it to? To allow haproxy to disable only services that are proven to be bad, but also make it easy to turn off all services on a box in one go.

1
  • please share your haproxy configuration with us. – c4f4t0r May 14 '19 at 16:08
1

If you want to have independent health checking for each service, and you should, then yes you need a backend for each. The good news is you don’t need to configure all the servers by hand. Set up DNS and HAProxy can discover your servers by using server-template and a resolvers parameter.

https://www.haproxy.com/blog/whats-new-haproxy-1-8/#dns-for-service-discovery

0

Your best bet would be to configure tomcat to use a connector (port) per app, using the appbase setting in server.xml. And then simply have backend per port.

Here's a how to from stackoverflow: https://stackoverflow.com/questions/23569327/deploying-multiple-applications-to-tomcat

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.