• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Affinity

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would be the best way to maintain session between clustered jvms in case there is no session affinity?
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this a distributed web applications? i.e you want to maintain the same session (single sign on) between different web applications?

Please elaborate on your scenario.
 
Vaibhav A. Karkhanis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the prompt reply......This not a distributed application as such...Just a single war file deployed on one jvm clustered with another jvm..so a request from a client can be served by either of the jvms....Just wanted to understand and know the best approach to maintain session in this situation. Also can I request for more detailed explaination on session affinity, as I am not too well versed with it....
 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using 'Clustering' between the App Servers - you do not have to do anything more. Sessions are automatically shared between clustered application servers.

Clustering ensures that Application Servers become aware of each others presence; and share sessions.

Remember, you could distribute load between your App Servers without 'clustering' too. This would be simply called Load Balancing. In this case, your Application Servers are not aware of each others presence, and do not share sessions. Only the Load Balancer in front (eg: Apache) distributes requests to either of these App Servers.

If you do not want to do Clustering, but yet want to distribute load across App Servers - you can make your Load Balancer 'Sticky' - that is requests from a particular user always go to the 'same' App Server - so you will not have to replicate sessions.
 
Vaibhav A. Karkhanis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually yes..the scenario is that there is clustering between app servers. So I think I should be fine if I don't explicitly maintain session states...Just to ensure I got the explaination in the previous post correct....If I have a web-tier in front of the application-tier, I can use it as the Load Balancer, incase I don't cluster the app-servers...am I correct?
 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vaibhav A. Karkhanis wrote:Just to ensure I got the explaination in the previous post correct....If I have a web-tier in front of the application-tier, I can use it as the Load Balancer, incase I don't cluster the app-servers...am I correct?



Yes, but in that case the web-tier MUST use Sticky Load Balancing.
The ONLY problem this will have is that if one of the App Server goes down, your users cannot fail over to other servers without losing their sessions.

Also, if your sessions are maintained in a common database, then this problem too does not occur.

If you have multiple App Servers, then you do have to have some kind of a load balancer in front anyway - to distribute the requests across App Servers. This Load Balancer can even be a hardware load balancer (very costly).

A typical example:
Apache as Load Balancer. Multiple App Servers (like Tomcat) behind it. Apache and Tomcat connected using JK2 module.

Clustering App Servers is not recommended in scenarios where there will be a very huge number of App Servers, as this could generate lot of traffic between them.
 
Vaibhav A. Karkhanis
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot James....The information is very useful..
 
reply
    Bookmark Topic Watch Topic
  • New Topic