Memory Replication & Multi-threaded Concurrent Access to HttpSessions

Glassfish V2 Memory ReplicationOne

Glassfish V2 Memory Replication

If you are using Memory Replication with GlassFish v2 and your web application involves multiple client threads concurrently accessing the same session id, then you may experience session loss even without any instance failure. The issue here is that our memory replication framework makes use of session versioning. This feature was designed with the more traditional http request/response communication pattern in mind.

For a number of types of applications however, this traditional pattern does not hold. Examples include many Ajax-related frameworks, the use of Frames, etc. Another example is when a page includes many static resources (e.g. jpg's). In these situations, most browsers will optimize the loading of these resources by using multiple parallel connections, each of which is handled by a separate request processing thread. If the application has already established a session then this too will involve more than one thread at a time accessing a single HttpSession.

We have provided a solution for these situations. Use the "relaxVersionSemantics" property in sun-web.xml - this allows the web container to return (for each requesting thread) whatever version of the session is in the active cache regardless of the version number. This is critical when multiple threads are interacting in an essentially non-deterministic fashion with the container.

Here is an example snippet from a sun-web.xml that demonstrates where to add this property:

<sun-web-app>
  <session-config>
    <session-manager persistence-type="replicated">
      <manager-properties>
	<property name="relaxCacheVersionSemantics" value="true"/>
      </manager-properties>
    </session-manager>
  </session-config>

.....
</sun-web-app>






 

 

Comments:

Thanks Iwhite. This was a very helpful tip to solve the session replication issue we were facing in our app. It took couple of weeks for us to get to your posting in some forum.

However, am curious, as to why this flag was not enabled by default, given most of the web apps today are Ajax enabled and/or have references to multiple resources per page. Is it that by enabling this flag, there are other trade offs like - performance or any other issues?

Posted by Karthik Krishnan on February 12, 2010 at 06:23 PM PST #

Thanks for help. I had the same problem after I upgraded my VM to 2 cores :)

Regards

Posted by Adrian Stanila on March 02, 2010 at 05:48 PM PST #

[Trackback] I have several clusters with Glassfish 2.1.1 in a BIG virtual environment and all worked fine &#8230; until I add new processors to this clusters. After upgrade I started to have problems with HttpSession replication. Starting debugging JXTA, Shoal and...

Posted by Random Bugs on March 02, 2010 at 06:27 PM PST #

I spent more then 2 weeks trying to resolve this issue, and finally landed to this page and boom. Its resolved now. thanks a lot for posting this.

Posted by Priya D on January 25, 2011 at 12:51 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

lwhite123

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today