Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat clustering & Hibernate

 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currenlty we are using plain old JDBC in our production environment, which is a Tomcat cluster with about 100 concurrent users 24/7 with all kind of applications related to the publishing industry.

For our new application development I would like to introduce Hibernate3 but I'm not aware of the technical implications, or issues, of using Hibernate3 within a clustered environment. Are all parts of Hibernate supported or not or are there some issues that I should be aware of.

Therefore : Does anyone have experience and wrote down some best practices?
for example : what is the best way to store a hibernate.Session
within a clustered environment to prevent opening and closing a
session each time it is used.
[ May 06, 2005: Message edited by: Arnold Reuser ]
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use Hibernate in a clustered environment, you'll probably want to use SwarmCache or JBoss TreeCache. Check this page for more information.

Usually you will create a new Session for each web request. It's not expensive to open up a new Session. SessionFactory objects are expensive to create, so you want to make sure you do that only once.
 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currenlty we are using OSCache, but from what I've seen now this is not an excellent solution. Which one do you prefer in your environment ( TreeCache or SwarmCache )? I assume in your situation the SessionFactory is cached instead of the Session and not bound to something like ThreadLocal?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally don't use Hibernate in a clustered environment. So, I wouldn't be able to recommend either one over the other. But, yes, I cache the SessionFactory in my applications and use a servlet filter to open/close the session for each web request. For an example of how I structure my code, you can check out the source code from this article that I wrote.
[ May 06, 2005: Message edited by: James Carman ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic