Session in web server or application server ?


General J2EE: Session in web server or application server ?

  1. Session in web server or application server ? (4 messages)

    We are designing a web application that will use JBoss as application server and Tomcat as a web server. Eventually, we expect to be running the application on several web servers and application servers, so the architecture has to be scalable.
    For those operations that require the preservation of a conversational state, we'd like to use stateful session beans on the application server rather than HttpSessions on the web server. This way, there's no problem sharing sessions across web servers when another web server is added, since it would not matter on which web server a client request is served.
    Yet, how the web client (servlets/JSPs) would keep using the same stateful session bean between request ? Do we need still to use HttpSessions to keep a reference to the appropriate stateful session bean ? In this case, do we still have to address the issue of HttpSession sharing across web servers ?

    Any help would be greatly appreciated. Thanks !!
  2. Hi Emil,

    Take a look at Tangosol's Coherence
    product. It will allow you to share data across a cluster easily, coherently and synchronously. We also have an HTTPSession Replication Module which leverages our Replicated cache and cluster-wide locking capabilities to maintain the state of you HTTPSession across the cluster and provide immediate and reliable failover of session data.

    Rob Misek
    Coherence: Easily share live data across a cluster!
  3. I would guess that you would still need to keep a hold of the reference to the stateful session bean, and thus, you'd need to keep your HttpSessions synchronized.

    However, you may be able to architect your load balancing such that the server serving the first request of a particular client services all requests of that particular client. Thus, you could avoid HttpSession sync'ing, because you'd know that a given client will always be served by the same JVM.

    This may require special hardware/software as well....
  4. I think you are right. We'll need to have some way of keeping the HttpSessions synch, shared, or something. Since we are using JBoss, I believe that session sharing is part of their 'clustering' feature.
    Thanks for you comments,
  5. Hey Emil,

    have a look at this article:

    javagroups seems to do sharing of HTTP sessions that contain little data accross multiple tomcat servers, so you could share the reference to the session bean.