Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate when and when not to use the second level cache  RSS feed

 
Salil Wadnerkar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our organization struggled with memory and performance issues pertaining to the 2nd level cache like ehcache, and we ended up removing the 2nd level cache. In your experience, is 2nd level cache worth it, and what are the typical practices employed by medium-sized web applications to mitigate these issues?
 
Tim Holloway
Saloon Keeper
Posts: 18636
70
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can cache in the following places:

1. Internal to an app

2. External to an app - sharable by multiple apps on one host

3. On an external cache server (for example when you're marshalling resources from multiple sources, although a DBMS may also internally cache stuff if many clients want it).

Ehcache is designed for level 2. You could use it with only a single local client app, but that's really only something I'd do if the app internal caching wasn't very good. Otherwise you end up with too many copies of the same data at various levels and that's just wasted storage and extra processing overhead.

In addition to the potential data redundancies, you also run into transactional issues. When you have multiple clients sharing a cache, they'd better all be playing nicely with transactions, or things can end up horribly out of sync.

A modest app might not benefit at all from a second-stage cache. Actually, even a large app might not benefit unless you need external tuning abilities.
 
Salil Wadnerkar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. That was informative.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!