tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Piavka <>
Subject Re: load balancing with routing with mod_jk in cluster
Date Mon, 28 Oct 2002 14:24:39 GMT

 Hi Brend,

> Hi,
> it seems that you want to use mod_jk on the nodes as balancer. We don't use it
> in that way. We have a load balancer in front of our nodes, which has a standby
> balancer, if the first one goes down. If we want to get your requested behavior,
> we had to configure this on our load balancer, not on the nodes. This balancer
> knows nothing about apache, tomcat and mod_jk. So I don't know how to manage it
> with mod_jk.
> I don't know how your config should work. Because if N1 routes to all other
> nodes and N1 goes down, how should your client know, that he had to connect to
> N2? You need some logic in front of your cluster, that the clients see your
> cluster as one big server. If you want something like standby or hot standby you
> must implement this in the front logic, not on the nodes. And I don't know if
> this is possible with jk1.
> Why do you limit the balancing to N1? Most of the work is done in your servlets.
> The balancing is not so hard, that it will bring your node down. If all nodes do
> balancing its no problem, if one node goes down.
> But may be I don't understand your scenario.

 Hope now i'll be clear with my needs and problems.
 I have two levels of web clustering/balancing. First one done with Linux Virtual
Server(lvs). The cluster has 3 nodes N1,N2,N3, which client sees as one big server.
Each node has apache + tomcat. N1 behaves as the loadbalancer and routes
the http requests between N1,N2,N3 apaches and it has persistence for the
http connections. So N1 is the master router/balancer. Now node N2 acts as
backup router/balancer. If N1 goes down, N2 detects this and activates
his backup router/balancer. This is implemented by Keepalived.
Also the http connections are replicated between N1 and N2, so client
does not loose connection if N1 goes down(unless it has connection to
apache on N1). Thus i have load balancing + high availability. This setup
works ok.

 Now the second level of clustering/balancing should be done between
apache servers and the tomcat servers on N1,N2,N3. I have 3 ideas how to
implenet this.

 First: session replication between tomcat servers done with  JavaGroups Library
and Tomcat Session Replication Library writen by Filip Hanik. But this
library, for tomcat 4.1, is currently in development and no code has beed
released for download yet.

 Second: Setup two balancers/routers on N1 and N2 with mod_jk1. By default
all apache servers will route requests to N1, and it will loadbalance them
between N1,N2,N3 tomcats.If N1 goes down(or just apache on N1), then N2
will get all request and loadbalance them between N2,N3(and N1 in case
only apache on N1 is down). -> This as i NOW understand can't be
implemented with mod_jk1. Maybe you have an idea how to implement this
without changing the first level clustering?

 Third: apache on N'th node will route all requests to the local tomcat
on the same N'th node. If local tomcat goes down, apache will start
routing requests to tomcats on other nodes which will be session persistent.
I tried to implenent this in two ways:

1) For each node: I set jvmRoute on each tomcat server.xml file to be dirrerent accross
all tomcat servers. On the local node for the local worker i set
local_worker=1 and for the remote workers local_worker=0.All workers with
same lbfactor=1.
 The problem with this setup is: if local tomcat worker goes down
then mod_jk just makes rountrobin between the remote workers without
session persistance, since remote workers have local_worker=0.

Since i need session persistance i tried another way:
2) For each node: I set jvmRoute on each tomcat server.xml file to be dirrerent accross
all tomcat servers. For all workers i set local_worker=1. But since i want
local apache direct reques to the local worker only(when it is up).
I made for the local worker lbfactor=100 an for the remote workers lbfactor=1.
 But it seems like mod_jk ignores the lbfactor then all workers have local_worker=1.
I also tried lbfactor=0 for the remote workers, and other values but this
did not change mod_jk behaviour.
 In all cases the old and new sessions were forwarded to one SAME remote
worker. Then i played with taking down/up workers the mod_jk routing
would work in unreasonable ways. I could not even understand the patters
of it's routing.(Then i was testing this i had only one local apache
running in the cluster, so that it will recieve all http request in the
cluster, so this behavoiour has nothing to do fith the first level routing/balancing).

 If you have any ideas how to make the third setup work, or you have other
ideas for setup i'll be very glad to hear.
 Thanks a lot.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message