You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Joseph Chiu <jc...@spun.com> on 2000/08/21 20:49:54 UTC

Tomcat 3.1 load balancing works with one gotcha.

TomCat 3.1 + mod_jserv (Apache) supports load balancing.  It works, and
supports sticky-sessions, but with one big caveat (see below).  (A
sticky-session is where a client, once it establishes a session on a
particular VM, returns to that VM for further processing).

To turn on mod_jserv's load balance features, you need to use additional
Jserv directives: ApJServBalance, ApJServHost, ApJServRoute, and
ApJServShmFile, like this:

### For every load-balance set, declare the hosts that belong to the set
ApJServBalance spunbalance LS1
ApJServBalance spunbalance LS2
# (add more here)

### For each load-balanced host, specify the protocol that it understands
ApJServHost LS1 ajpv12://dratini:8008
ApJServHost LS2 ajpv12://dratini:8001
# (add more here)

### Define the "route tag" that mod_jserv uses to support sticky sessions on
each host
# For example, sessiosn on LS1 will get a session cookie like this:
# JSESSIONID=To1028mC5487727979769673At.JS1
ApJServRoute JS1 LS1
ApJServRoute JS2 LS2
# (add morehere)

### mod_jserv uses a shared-memory file to coordinate the VM up/down
information
# among the many httpd processes
APJServShmFile logs/jserv_shms

Finally, you need to change your ApJServMount to use the balance set,
instead of going to a single VM:

# Instead of ApJServMount {mtpoint} ajpv12://host:port/context

ApJServMount /spun      balance://spunbalance/spun
ApJServMount /free-dvds balance://spunbalance/promo-dvd

There, that should do it.

Now, THE ONE BIG CAVEAT:

The load-balancing cookies don't work for the root context.  (Apparently a
purposeful design choice.)   So, you won't be able to get either of these to
work:

ApJServMount default   balance://spunbalance/root

or

ApJServMount / balance://spunbalance/root


As I understand, the designers wanted to avoid using a single jsessionid
cookie that would be shared by all web applications.  Put differently, each
servlet-collection is supopsed to have its own distinct session.  If a
root-context session were allowed to set a session-cookie, that cookie would
apply globally site-wide.

In my own personal case, I actually *want* the global-cookie behavior, but
there's good reasons to support The Tomcat Way.   Former JServer users
switching to Tomcat might find that their application "breaks" for this
reason.  It certainly was the case when we switched our e-commerce site (to
sell new/used CD/DVD/Games) to Tomcat.  Alas, the faq-o-matic was slightly
misleading, and it took me nearly 6 hours of digging around to finally
figure out what the heck was going on!

I wanted to put this on the faq-o-matic, but faq-o-matic new-account signup
is broken.  So, hopefully, it'll be accessible to others in the list
archives....  Hope it helped.

Our words of the day: jvmroute apjservbalance jserv cookie requestimpl
setjvmroute load balancing
----
Joseph Chiu, Systems Engineer. w:(626) 229-3148 c:(626) 643-2448
Spun.com: Your Online Entertainment Exchange.

"'Have a great day.'  Hmm, sounds good, but let's run it through legal
first..."


Re: Tomcat 3.1 load balancing works with one gotcha.

Posted by "yhs@mimic.onesourcecorp.com" <yh...@mimic.onesourcecorp.com>.

On Mon, 21 Aug 2000, Joseph Chiu wrote:

> TomCat 3.1 + mod_jserv (Apache) supports load balancing.  It works, and
> supports sticky-sessions, but with one big caveat (see below).  (A
> sticky-session is where a client, once it establishes a session on a
> particular VM, returns to that VM for further processing).
> 
><SNIP> 
> Now, THE ONE BIG CAVEAT:
> 
> The load-balancing cookies don't work for the root context.  (Apparently a
> purposeful design choice.)   So, you won't be able to get either of these to
> work:
> ApJServMount default   balance://spunbalance/root
> or
> ApJServMount / balance://spunbalance/root
> 


actually that works IMHO from what i understand since it does seem to be
ok for me. it works with only one servlet on the root though..as shown  :

A1 <- request 1
A1 -> response 1
B2 <- request 1
B2 -> response 1

i.e. its sticky with the same servlet not with multiple servlets so A1
will field all requests from user 1 but the same doesnt apply to B
(i.e. it doesnt select B1). dont know if im making myself clear here....or
confusing everyone...

> 
> As I understand, the designers wanted to avoid using a single jsessionid
> cookie that would be shared by all web applications.  Put differently, each
> servlet-collection is supopsed to have its own distinct session.  If a
> root-context session were allowed to set a session-cookie, that cookie would
> apply globally site-wide.
> 

thats good.

> In my own personal case, I actually *want* the global-cookie behavior, but
> there's good reasons to support The Tomcat Way.   Former JServer users
> switching to Tomcat might find that their application "breaks" for this
> reason.  It certainly was the case when we switched our e-commerce site (to
> sell new/used CD/DVD/Games) to Tomcat.  Alas, the faq-o-matic was slightly
> misleading, and it took me nearly 6 hours of digging around to finally
> figure out what the heck was going on!

+1 to keeping it the same and changing the FAQ. please dont fiddle
with mod_jserv.so unless necessary. it took a loong time to get that code
right.

> 
> I wanted to put this on the faq-o-matic, but faq-o-matic new-account signup
> is broken.  So, hopefully, it'll be accessible to others in the list
> archives....  Hope it helped.

-Ys-
yhs@mimic.onesourcecorp.com