Rajani Gummadi wrote:Hi,
I was reading through the api for "ServletContext" at ...... running on different nodes, share the same virtual machine.
There is only one JVM per node, so definitely its not shared by different nodes, rather each have its own JVM. While every part of the web-application is replicated on each node, such as servlets,
JSP, servlet-context, etc. Its only the HttpSession objects that are migrated/moved between the nodes. Lets say that a request comes from a client to the web-app, the load-balancer server delegates the request to node 1, there the session object is created and the response is sent back to client along with session cookie.
Now, the client again makes a request sending in the session-id, now the load-balancer server delegates the request to node 2, which doesn't have that session object, which is realized by the container at node 2. Now the question arises how to process the request. Hence, there is now session migration i.e. the specific session (found by its session id)is passivated on JVM at node 1, and activated on JVM at node 2.
Having the session, since as told before every thing is replicated. The container creates a new
thread of servlet A(assuming the request was bound to it) and processed response is sent back to the client. This is a general view of how distributed applications work.
Regards,
Gaurav