You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vjeran Marcinko <ma...@jware.net> on 2002/02/10 07:39:59 UTC

Load balancing app context ?

Hi.
Just a short question.
I have a web-app that has to have some global
sharing context for my web-app in Tomcat's load
balancing case (multiple JVMs).
Till now, I simply was defining all shared variables
outside service() method, so different HTTP request
can have access to these instance variables (usually
initialized in init() method). 
So my short question is :
Will this work in load balancing case, when I have 
multiple JVMs ? I'm afraid each JVM will have its
own instance of this servlet, thus having each own
instance of this servlet's instance variable, thus data
stored in this variable during one HTTP request cannot
be accessible to other HTTP request, because they are
running on different JVMs..Right ?

Thanx,
Vjeran




--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Load balancing app context ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sun, 10 Feb 2002, Vjeran Marcinko wrote:

> Date: Sun, 10 Feb 2002 07:39:59 +0100
> From: Vjeran Marcinko <ma...@jware.net>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Load balancing app context ?
>
> Hi.
> Just a short question.
> I have a web-app that has to have some global
> sharing context for my web-app in Tomcat's load
> balancing case (multiple JVMs).
> Till now, I simply was defining all shared variables
> outside service() method, so different HTTP request
> can have access to these instance variables (usually
> initialized in init() method).
> So my short question is :
> Will this work in load balancing case, when I have
> multiple JVMs ? I'm afraid each JVM will have its
> own instance of this servlet, thus having each own
> instance of this servlet's instance variable, thus data
> stored in this variable during one HTTP request cannot
> be accessible to other HTTP request, because they are
> running on different JVMs..Right ?
>

You are correct.  Different JVMs cannot access the same Java variables
directly, no matter how you declare them.  To share information between
JVMs, you will need to use some external mechanism (such as a database or
EJBs), or perhaps RMI calls to copy changes from one JVM to the others.

> Thanx,
> Vjeran
>

Craig


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>