You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Peterson <da...@orbitec.com.au> on 2001/03/02 11:04:32 UTC

Session beans and multiple tomcat servers ?


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.

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 ?

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.

Any guidance or relevent experiences much appreciated ...

Thanks in advance.


David Peterson



Re: Session beans and multiple tomcat servers ?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
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



RE: Session beans and multiple tomcat servers ?

Posted by Andrew Gilbert <an...@soundbite.com>.
One option is a load balancer that will handle session affinity, either on
it's own or through a custom cookie/url rewrite. This is a problem with
almost all web application server solutions, certainly not unique to
Tomcat/JSP.

-----Original Message-----
From: peterson@localhost.localdomain
[mailto:peterson@localhost.localdomain]On Behalf Of David Peterson
Sent: Friday, March 02, 2001 5:05 AM
To: tomcat-user@jakarta.apache.org
Subject: Session beans and multiple tomcat servers ?




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.

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 ?

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.

Any guidance or relevent experiences much appreciated ...

Thanks in advance.


David Peterson



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