Monitor Liferay cache behaviour with JConsole
Company Blogs July 27, 2011 By Armin Cyrus Dahncke Staff
A crucial point for any project is the use of cache strategies, especially when you try to implement a project the first time on a new infrastructure. Therefore I will give some hints how you can easily get confident with our ootb caching strategies.
So lets get started with my prerequisites.
You download any tomcat bundle of liferay, I used 606 our latest community edition of the portal with tomcat 6.
As JConsole needs to connect to tomcat you will need to give tomcat some extra configuration. I added the necessary opts to catalina.sh (on windows that would be catalina.bat) somewhere near line 257.
(I have my catalina.sh stored in 606workspace/bundles/tomcat-6.0.29/bin)
CATALINA_OPTS="$CATALINA_OPTS \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=12345 \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false"
Now we need to tell liferay that we would like to evaluate the ehcache statistics. We need an entry in portal-ext.properties for that, as this costs a small portion of performance it is disable be default.
My portal-ext.properties file is stored in /606workspace/bundles/portal-ext.properties, where bundles is the directory which includes tomcat*/bin
# Set this to true to enable Ehcache statistics.
So much for the setup, we can start the portal now (exec startup.sh in a shell or double click startup.bat on windows in tomcat bin folder)
Once the Portal is started go forth an create some WebContent in Liferay CMS and put the article on any page.
On my end I just used
and placed a Web Content Display Portlet on the page which used one content I have created earlier.
So now we can start jconsole from shell or commandline by typing in
hit enter and it starts rightaway, as long as you have a full jdk installed.
JConsole has a startup screen
We will choose org.apache.catalina... to connect to tomcat and directly land on the overview page in jconsole. To look at the cache hits we navigate to MBeans and then on the left tree we will walk following path.
Then you will have a lot of classes inside this container, which represent the caches of different entities etc., as we want to monitor the statistics of rendered journal content, the following class is what you want to find:
Once you have discovered the class unravel the details by clicking on it and select
Now the cache statistics overview will show up and every time you refresh your browser on
the statistics will change.
Have fun exploring