You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bernd Koecke <bk...@schlund.de> on 2001/04/05 13:19:25 UTC

mod_jk in a cluster

Hi,

we want to use tomcat 3.2.1 in a cluster-environment. This is not a
request that someone else should code something. I think I have a
solution, but may be others are interested in it too.

We have, lets say three cluster-computer (server) and one simple
load-balancer. The load-balancer doesn't look in the Packets and doesn't
know something about Sessions etc. The server are running with apache +
tomcat. apache with mod_jk. The following things could happen:

- a request arrives at a server without a session => it should be routed
to tomcat on this server
- a request with a session on another server arrives => should be routed
to the other server
- a request with a session on this server arrives => should be routed to
this server
- a request with a session on a server which is down arrives => use
another server and send him the request. The session is not present
there and our application handles this

Is there a way to get this with existing modules? My solution plays
around with mod_jk as follows:

The easiest way is to switch off load-balancing and recovering with an
additional property in the config. But I could understand if someone
says this should be a new module. But it could work with mod_jk. For
this I use the lb_worker which controls three ajp13-worker on every
server. The ajp13-worker are connected to the three tomcats. Now I have
two possibilities:

- set the lb_value of the worker for the local tomcat to 1 and >1 for
the other workers, then switch off load-balancing by setting lb_factor
to 0.0. This should give an error because of the validate-function, but
it could be fixed with a small patch.
- setting the lb_value for the worker which is connected to tomcat on
the same server to -1 and 1 for the others and the lb_factor to a
negative value. 

Both solutions are incorrect if one of the tomcats goes down, because of
the recovering. So I come to the first idea, to use an additional flag.
If it works here, are there interests in a diff of mod_jk?

Bernd
-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: bk@schlund.de

Re: mod_jk in a cluster

Posted by Bernd Koecke <bk...@schlund.de>.
James Courtney wrote:
> 
> With the exception of failover (case 4 below), I believe that the first
> three cases can be handled by having your load balancer be "sticky" by
> client address to any of the app servers (machines running Apache with
> Tomcat).  Thus if your load balancer receives a request from client
> some.client.net and round robin assigns the request to server B, given
> servers A, B, and C, then all subsequest requests from some.client.net
> should be routed to server B.

Our load balancer is very poor. He does weighted round robbin and the
weights are the system load of the cluster computer. He can't look in
the IP-Packets and doesn't know anything about sessions. And he also
doesn't cache the client-ip's. So the load balancer can't handle the
stickyness of the sessions. This is handled in the past by mod_jserv in
the apache-webserver on the cluster. But now we want to use tomcat with
mod_jk because of 2.2servlets and the better handling of SSL in ajp13.
After playing around with mod_jk I build a new worker, my needs are more
like a router (because of the sessions) with failover and not a load
balancer (lb-worker). So I think my first idea to add a new property to
the lb-worker wasn't clever. mod_jk is compiled, so I have to test it.
This will take a little time.

>  If B ever goes down the session information
> from some.client.net is lost and the client will have to retry their
> session.  To implement a failover system is highly non-trivial and my
> understanding is that most application servers (even commercial ones) do not
> support this.  In fact I'm told by several coworkers who worked formerly for
> BEA and know people there up to and including the B, the E, and the A that
> WebLogic only recently got failover with session replication right.  To make
> this work you will need a somewhat complicated session replication mechanism
> between all app servers which is n(n-1) replications (in this case 6) if
> replication is done between all servers and at best n choose 2 (in this case
> 3, or an extra session "write through" per request if you prefer)
> replications if each app server has a single failover server.  That can be a
> lot of network traffic and a lot of new code.  If I'm wrong and there's a
> way to make this work in Tomcat then kudos to all involved and let me know
> how to do it:)!
> -Jamey

I agree. Session replication is a solution but it isn't clever. You have
to mutch traffic for the hopefully rare case of a server crash. So we
make the following: If you have a session on a server wich is crashed,
you get a new one on a server which is up and start at the beginning.
This is handled by our servlets. So with my new worker in conjunction
with our servlets I should get the desired behaviour. Thanks to the
developers of mod_jk! My C-knowledge is not very well, but with the help
of the comments and variable/function-names in the source I got it. The
code is a little bit special to our purpose, but if there are interests
in the small code I could send it to the list. But I think we should
wait till it is tested :).

Bernd
-- 
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: bk@schlund.de

RE: mod_jk in a cluster

Posted by James Courtney <ja...@yahoo.com>.
With the exception of failover (case 4 below), I believe that the first
three cases can be handled by having your load balancer be "sticky" by
client address to any of the app servers (machines running Apache with
Tomcat).  Thus if your load balancer receives a request from client
some.client.net and round robin assigns the request to server B, given
servers A, B, and C, then all subsequest requests from some.client.net
should be routed to server B.  If B ever goes down the session information
from some.client.net is lost and the client will have to retry their
session.  To implement a failover system is highly non-trivial and my
understanding is that most application servers (even commercial ones) do not
support this.  In fact I'm told by several coworkers who worked formerly for
BEA and know people there up to and including the B, the E, and the A that
WebLogic only recently got failover with session replication right.  To make
this work you will need a somewhat complicated session replication mechanism
between all app servers which is n(n-1) replications (in this case 6) if
replication is done between all servers and at best n choose 2 (in this case
3, or an extra session "write through" per request if you prefer)
replications if each app server has a single failover server.  That can be a
lot of network traffic and a lot of new code.  If I'm wrong and there's a
way to make this work in Tomcat then kudos to all involved and let me know
how to do it:)!
-Jamey

-----Original Message-----
From: bk [mailto:bk]On Behalf Of Bernd Koecke
Sent: Thursday, April 05, 2001 4:19 AM
To: tomcat-dev
Subject: mod_jk in a cluster


Hi,

we want to use tomcat 3.2.1 in a cluster-environment. This is not a
request that someone else should code something. I think I have a
solution, but may be others are interested in it too.

We have, lets say three cluster-computer (server) and one simple
load-balancer. The load-balancer doesn't look in the Packets and doesn't
know something about Sessions etc. The server are running with apache +
tomcat. apache with mod_jk. The following things could happen:

- a request arrives at a server without a session => it should be routed
to tomcat on this server
- a request with a session on another server arrives => should be routed
to the other server
- a request with a session on this server arrives => should be routed to
this server
- a request with a session on a server which is down arrives => use
another server and send him the request. The session is not present
there and our application handles this

Is there a way to get this with existing modules? My solution plays
around with mod_jk as follows:

The easiest way is to switch off load-balancing and recovering with an
additional property in the config. But I could understand if someone
says this should be a new module. But it could work with mod_jk. For
this I use the lb_worker which controls three ajp13-worker on every
server. The ajp13-worker are connected to the three tomcats. Now I have
two possibilities:

- set the lb_value of the worker for the local tomcat to 1 and >1 for
the other workers, then switch off load-balancing by setting lb_factor
to 0.0. This should give an error because of the validate-function, but
it could be fixed with a small patch.
- setting the lb_value for the worker which is connected to tomcat on
the same server to -1 and 1 for the others and the lb_factor to a
negative value.

Both solutions are incorrect if one of the tomcats goes down, because of
the recovering. So I come to the first idea, to use an additional flag.
If it works here, are there interests in a diff of mod_jk?

Bernd
--
Dipl.-Inform. Bernd Koecke
UNIX-Entwicklung
Schlund+Partner AG
Fon: +49-721-91374-0
E-Mail: bk@schlund.de


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com