• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Object references in a clustered container

 
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I heard, if the servlet container is clustered, then requests will be handled by different servers in the cluster. Also, in such a situation, each JVM (server) will have its own servlet. If that is so, what happens to the object references made by the servlet? For example, if the servlet object refers to a particular object, which should be updated at each request, what will happen?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is yet another good reason to stay away from instance variables in servlets.

For containers that use session replication, make sure that any object bound to session (directly or indirectly) implements serializable and your session scoped objects will by synced by the container. Request scoped variables are always local to a particular request so they aren't affected by clustering.

Just as with instance variables in servlets, you want to make sure that any application scoped variables aren't specific to one node.
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. You said that it is necessary to implement Serializable. Does this mean that these objects will be sent across the servers using RMI?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe it is up to the container builders to worry about how the are transported. I know Tomcat sends them over tcp but I don't know any more about it.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yohan Liyanage:
Thanks. You said that it is necessary to implement Serializable. Does this mean that these objects will be sent across the servers using RMI?



Take a look at Terracotta http://www.terracotta.org. Not only can you cluster your sessions but you can cluster POJOs as well. The over head is not as bad as serializing the object every time it gets updated.




[BPSouther: Fixed link to terracotta]
[ August 17, 2007: Message edited by: Ben Souther ]
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Thats an amazing tool for sure.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No matter how you do session migration it certainly has come overhear.
There are some ways be which this migration can be minimized.

Might want to have a look at those.
Session Migration
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic