Hibernate second level cache with JBoss Cache 3

The project I have been working on lately is a web application running on JBoss 5. The production setup contains a cluster of JBoss instances behind Apache proxy which acts as a load balancer. So far load testing results have been encouraging and load tests also revealed couple bugs.

Our persistence layer is using Hibernate so the next step in caching was to enable Hibernate's second level cache. There are various options but in our clustered environment JBoss Cache was the choice. But getting started with it took some time.

The easiest way is to use 'all' server setup from the JBoss 5 and enable second level cache in Hibernate settings. The JBoss community wiki page provides an example for the setup. Also your JPA entity annotations or mappings need some changes as well because you need to define caching strategy for them.

Taking a look at the documentation of JBoss Cache reveals huge amount of configuration options. Luckily only some of them are relevant for Hiberante second level caching. Be aware that JBoss Cache has been around for some time so some of the older tutorials and blog posts are outdated. At the moment JBoss Cache version 3.x is the recommended one.

In case of caching it is very important to run proper load tests after each configuration modification to verify the performance gain or loss. At the moment I have my test setup running on Apache JMeter. It creates similar load to the server based on historical usage data. Another area of testing is to verify that cluster's caches are having their state updated properly.

I have been experimenting with JBoss Cache only for a day so it will take a bit more time before I can give my opinion or better advices. So, follow my RSS feed to learn more - hopefully soon there will be an update.

Comments

No comments yet

Add Comments