David Peterson wrote:
> Hi Everybody,
>
> I have a question about the architecture of tomcat and the sharing of
> beans (typically accessed by JSP page code) with a scope of "session".
>
> It seems to me that one major problem with JSP and session-scoped beans
> on tomcat (and possibly other servlet engines ? i'm not trying to bag
> tomcat specifically here !) is that I am restricted to a hardware
> architecture of a *single webserver* running tomcat.
>
Tomcat stand-alone does not support load balancing as you are describing
it. However, if you declare your web application to be <distributable> in
the web.xml file, and your servlet container supports it (which Tomcat does
not), you can indeed have a load balanced environment. However, there are
two key issues:
* Your application must ensure that all servlet attributes that you
store implement java.io.Serializable so that the container can
move your session to a different machine if it wants to.
* Your container must obey the requirement in the servlet spec that,
at any given point in time, all requests for the same session are being
handled by the same JVM. In other words, containers that support
session migration can only do so "between" requests.
>
> If I wish to run a 'load-balanced' (dns round robin most likely) server
> configuration with multiple instances of tomcat sitting behind the same
> URL, is there any known way in which to share session-scope java beans
> created by one tomcat server across the other servers ?
>
Not with Tomcat standalone.
Apache JServ (and Tomcat running behind Apache) solve this as follows:
* Requests that are not part of a session can be forwarded
to any available container instance.
* Once a session is established, all future requests for that
session will come back to the *same* container instance.
This is accomplished by modifying the session identifier to include a
reference to the originating host, which will therefore be included on
subsequent requests.
>
> The only way I can see to solve this problem is to push all session
> information to a backend database accessible by all the webservers, and
> to look up the session information from the database *each* time the
> user moves from page to page (and potentially across tomcat servers).
> This seems kludgy, and the database access requirements defeat both the
> simplicity of the session-bean approach, and add overhead to the very
> scalability and performance that you're trying to achieve by using
> multiple servers.
>
That's the other way to do it.
>
> Any guidance or relevent experiences much appreciated ...
>
> Thanks in advance.
>
> David Peterson
>
Craig McClanahan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]