tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Chiu" <jc...@spun.com>
Subject Tomcat 3.1 load balancing works with one gotcha.
Date Mon, 21 Aug 2000 18:49:54 GMT
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..."


Mime
View raw message