Re: Custom load balancing logic

From: Willy Tarreau <w#1wt.eu>
Date: Sun, 27 Jun 2010 08:00:00 +0200


Hi,

On Mon, Jun 21, 2010 at 04:23:32PM +0530, manu tripathi wrote:
> Hi,
> I am a newbie and need to setup a load balancing setup where haproxy will
> distribute load between 2 or 3 tomcats(each tomcat resides on a different
> machine) based on a parameter coming in the URL. Based on that parameter I
> have to carry on some logic and implement an algorithm in java/c and then
> send that request to the corresponding tomcat. Please explain how to do
> that. For eg. I have unique Id coming in as the URL parameter. The tomcat
> installed in each machine has a DB which can only allow a range of that ID.
> So I want to apply the logic on the haproxy (either by some reg ex or
> implementing some load balancing class of haproxy) such that the request
> containing that ID belonging to the particular machine is routed to that
> machine. Please help??

You should take a look at the ACLs in doc. There's a whole set of ACLs that could be used in your case, most likely url_reg and url_sub which respectively match a regex and a substring. For instance, it might make sense to look for substring "id=1" or "id=2" if you know that all IDs 1xxxx or 2xxxx are to be matched.

There's just something unclear in your case, as you're saying that haproxy will perform the load balancing itself, and later you're saying that you want to be able to select the server from another place (your "java/c" which I don't understand where you want to place it). Also, each time you want to force load balancing decisions, you have to define how you want the system to behave when the selected server is dead (error, redirect to another one, etc...). This is very important because it is what describes what your architecture will look like, and will imply some major choices for your configuration.

Willy Received on 2010/06/27 08:00

This archive was generated by hypermail 2.2.0 : 2010/06/27 08:15 CEST