tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernd Koecke ...@schlund.de>
Subject Re: load balancing with routing with mod_jk in cluster
Date Thu, 24 Oct 2002 08:36:10 GMT
Hi,

This part of the docs came from me and we use such a configuration here at work, 
but we use tomcat 4.0.x and mod_jk1.

Alexander Piavka wrote:
>  Hi,
> I have lvs cluster of 3 nodes, on each node i have apache1.3 + tomcat4.1.12+mod_jk
> serving identical data. The http service on lvs is configured with persistent connection.
> So in normal operation i want that apache on each node will route requests
> to tomcat on the same node.

This is done by mod_jk and the jvmRoute in tomcat's server.xml.

> 
>  In addition if ,for example, i want to take down tomcat on one node, then
> i would like that apache on the same node will start routing requrests to
> the other two tomcats on the other nodes. Now if the tomcat comes back
> then i would like to continue to route requests only with an old session
> to to the other two tomcats.
>  How can i enable this with load balancing in mod_jk?
> As i understand this can be done with setting local_worker=1 for all
> tomcat workers or only for the local tomcat worker.
> and how do i tell apache to forward the requests to load balancers
> on the other two nodes? How apache knows what there are other two remote
> load balancers, i.e should i somehow add them to local worker.properties?
> what lbfactor values should i give to the local and remote tomcat workers?

Here we have to clarify some things. You have only one load balancer in your 
system and thats the one in front of your nodes. We should name the module in 
apache mod_jk and this has one lb_worker. But we should not think about it as a 
load balancer. That makes things easier. This lb_worker consists of a number of 
e.g. ajp13 worker. These ajp13 worker are holding the connection to the tomcat 
instance on the same (local) and on the other nodes. The mod_jk module will 
route the requests with a session to the node which generated the session, by 
the extension of the session id, the jvmRoute. Now you have sticky sessions, 
without session replication.

When a request without a session arrives it will be balanced by the module to 
one of the nodes. If you set 'local_worker=1' only for the local ajp13 worker, 
these requests will be routed only to the local worker. If this local worker is 
down the new requests will be routed to one of the other nodes. But when you set 
local_worker_only=1 for the lb_worker, these requests will get an error 
response. We need this for the right behavior when we switch off one node for 
maintenance.

We have the lb_value of all nodes set to the same value, because we don't use 
the balancing of mod_jk.

> 
>  How can i take down the tomcat cleanly, so that it goes down only
> after all old sessions to it end. As i have read in Workers HowTo
> this can be done with some special port if i set local_worker_only=1 for
> the load balancer worker, but how i switch this port off before shuting
> down tomcat? Or the old sessions can be just routed to another
> load balancers. If so then how?

This functionality comes not from apache-mod_jk-tomcat. When we want to switch 
off one node, we switch off a special port on this node. The load balancer calls 
this port of all nodes periodically. If this port is off the node will be marked 
as down. After this, the node doesn't get any requests. The balancer doesn't 
know anything about sessions, he does only round robin balancing. The routing 
for the sessions is done by mod_jk on the other nodes. Now the switched off node 
gets only request with a session on it, no new ones. Because of the session 
timeout after some time there are no active sessions on the node. You can see 
this e.g. by session listeners. Now you can savely shutdown tomcat without 
loosing session data. But the session timeout will be reset with every request 
which accesses the session.

Its possible to save session data before shutdown and read it in after restart, 
but this is dangerouse in two ways. If you change a class which is saved in a 
session you could get problems when you try to read the object in after restart. 
And the second one, what should be done, if a user sends a reuqest while the 
tomcat with his session is down?

You could use session replication, but be aware of the extra traffic. Especially 
if you use clustering for scalability and not only for high availablitity.

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


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message