Anonymous user session - Best practice

You might have required to enable session for Anonymous user for some business requirement and you might have done it by creating a custom property in portal configuration service called WP NavigatorService.
Creating a new custom property called public.session and value as true for WP NavigatorService.
This setting creates anonymous session for every user and for every portlet, which will definitely be a performance hit.

Now you may think how it will be performance hit, let me explain in brief
If the portlet does not require a session for critical operation, then perhaps any subfunctions within the portlet require the session can be suppressed to anonymous users.
This should be evaluated for each individual portlet.

If request.getPortletSession() or request.getPortletSession(true) are called when the user is not logged in and WebSphere Portal is not configured to use a session for anonymous users, each request from each client creates an extraneous PortletSession object that is lost and consumes JVM memory. This causes more frequent JVM garbage collection and hurts overall WebSphere Portal performance.


To overcome this performance issue, we can make use of JSR 286 new concept called Container Runtime Options.
With this concept, we can create Anonymous user session for a perticular portlet.

All you have to do is just add <container-runtime-option> tag to portlet.xml for a specific portlet you want to enable anonymous user session.
com.ibm.portal.public.session is the parameter name and set value as true.
       
Example:-

<container-runtime-option>
  <name>com.ibm.portal.public.session</name>
  <value>true</value>
</container-runtime-option>

4 comments:

Naga said...

Very informative Neeraj

Ibon said...

Does this work also in cases where sometimes the user is anonymous and sometimes is logged in?
Thanks.

Neeraj Sidhaye said...

Yes Ibon, it would definitely work in both the cases.

Ibon said...

Thank you, Neeraj!