Previously I did some initial setup for JBoss Cache and now I have tested it a little bit on a cluster setup. The setup has two virtual linux images with JBoss 5. In front of them is Apache HTTP for proxying and load balancing.
I started up JBoss on both machines with -c all. This setup has clustering turned on as a default so instances found each other and established JGroup communication channels. Then I deployed the .ear file directly to the deploy directory on each server as the farm deployment did not look too promising. The Apache proxy and balancer were already correctly configured so cookies and sticky sessions worked fine.
The big question is naturally how the performance improved. First I ran a load test without second level caching or query caching in order to have a baseline for comparisons. Then I turned Hibernate second level cache on and executed the same load test. The results were showing around twofold throughput as the average response times halved. I also tried turning on query caching but I did not experience any significant difference with it. Maybe I did not have proper configurations.
I also learned that it is not a good idea to modify data on the DB used by the cluster with Hibernate second level caching on. The nodes communicate sending invalidate messages to each other when data is changed and needs to be refreshed. Modifications outside the cluster mean that the cached data is stale but nodes do not know about it and resulting various errors...
Archive for May of 2009
Some experiences with JBoss Cache as Hibernate second level cache
May 28, 2009Hibernate second level cache with JBoss Cache 3
May 25, 2009
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.
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.
Walkera 4#3b and sauna
May 19, 2009
As mentioned before, I ordered a new toy for myself. This toy is a tiny RC helicopter - Walkera 4#3b. Despite its tiny size and relatively cheap price it has 4 channel controller and it actually flies. Because it is electrical and tiny, it is possible to fly indoors. I did not have any experience with helicopters so I ended up crashing and crashing until I learned how to keep it hovering. Great fun and plenty of challenge!
The sauna in the topic has nothing to do with helicopters. Instead, we found a nice gym in Kirkcaldy and it has a proper sauna. I would pay the membership fee almost just for sauna usage but being able to do some work out is a big plus.
The sauna in the topic has nothing to do with helicopters. Instead, we found a nice gym in Kirkcaldy and it has a proper sauna. I would pay the membership fee almost just for sauna usage but being able to do some work out is a big plus.
What I have been up to lately
May 05, 2009
I have met some other Finns living in Scotland in couple different events. For some reason most of the other Finns were women married to Scottish men. Maybe Finnish men took Scottish women to Finland - or they avoided them altogether. Anyways, the wappu event organized by Scottish-Finnish Society in Edinburgh was a great way to meet up and taste excellent home made sima.
On the photography front I have taken plenty of photos but I have not spent fortunes on new camera gear. I think the current setup is decent enough and might need only couple minor things. A set of Kenko extension tubes is most likely next thing to get. Obviously the set is never complete, there is always a better lens or camera to buy.
At work it has been busy enough. The project has been progressing nicely and working with GWT/GXT has been a good experience. The most recent highlight was from today as I set up a soft RAID 1 for new hard drives in my Ubuntu dev box. Of course I did not figure out the setup myself, the instructions were clear enough.
Oh yea, I also ordered a new toy for myself. It is still on the way from Hong Kong so have not tried it out, yet...
On the photography front I have taken plenty of photos but I have not spent fortunes on new camera gear. I think the current setup is decent enough and might need only couple minor things. A set of Kenko extension tubes is most likely next thing to get. Obviously the set is never complete, there is always a better lens or camera to buy.
At work it has been busy enough. The project has been progressing nicely and working with GWT/GXT has been a good experience. The most recent highlight was from today as I set up a soft RAID 1 for new hard drives in my Ubuntu dev box. Of course I did not figure out the setup myself, the instructions were clear enough.
Oh yea, I also ordered a new toy for myself. It is still on the way from Hong Kong so have not tried it out, yet...