tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Turner, John" <>
Subject RE: load balancing with routing with mod_jk in cluster
Date Mon, 28 Oct 2002 14:40:12 GMT

Can you explain how having Apache load balance to Tomcat helps in your

As you've explained:

N1: Apache + Tomcat
N2: Apache + Tomcat
N3: Apache + Tomcat

Apparently, you have it setup so that your 3 Apaches get load-balanced
traffic.  How then, does forcing N1-Apache to load balance to N1-Tomcat,
N2-Tomcat, N3-Tomcat solve anything or increase your performance?  

Seems like you will just be spinning in have N1 deciding which
N to send a request to, with failover, but then you have each N deciding
which T to send a request to.  So a request comes in, N1 decides to send it
to N2, but then the connector on N2 decides to send the request to the
Tomcat on N3????  Yikes.

I think you might be able to make a difference if you were to separate your
Apache and Tomcat services, like this:

N1: Apache
N2: Apache
N3: Apache

T1: Tomcat
T2: Tomcat
T3: Tomcat

6 machines instead of 3.  Then, on each N, you have a JK load-balancing
setup that includes T1, T2, and T3.  Maybe I am missing something, but I
don't see what advantage load-balancing to Tomcat gives you when the Tomcats
are on the same machines as the Apaches, especially if one or more of the
Apaches goes down.   I also don't see what advantage you are getting making
N1 do both load routing and simple request serving.

As Bernd mentioned, a typical scenario would be:

Internet -> Load Balancer -> Apache server -> Tomcat server

All on separate boxes.  Right now you have everything on one box.  I would
think that if the Apache on N1 is down, it would be safe to assume that the
Tomcat on N1 is down also, so it seems like a lot of work for not much

I'm not criticizing, just trying to understand what advantages you are
getting with your environment.  Yes, the failover is nice, but so far I see
no advantage to doing all of that load-balancing.  Have you done any load
testing on this scenario?  I would think your time per request would
actually go up...there is a lot of processing/decision-making going on just
to serve a simple request.


> -----Original Message-----
> From: Alexander Piavka []
> Sent: Monday, October 28, 2002 9:25 AM
> To: Tomcat Users List
> Subject: Re: load balancing with routing with mod_jk in cluster
>  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:

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

View raw message