Your browser (Internet Explorer 7 or lower) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

X

Navigate / search

Liferay Terracotta Configuration

Caching is one of the most important technique to improve performance of any solution. By default Liferay portal implements caching using EHCache framework. When we implement clustered deployment of Liferay portal solution, we need to make sure we synchronize caches across all the nodes. Cache synchronization is a very common issue to deal with any scalable solution. Essentially there are two types of options to solve the issue.

    1. Using Cache Replication
    2. Using Distributed Cache

EHCache provides different way of implementing cache replication. Also Liferay supports cache replication using Cluster Link. But if we need highly scalable solution where in we are planning to keep lot of data in cache then distributed cache is better option. In distributed cache individual node keeps only required data in cache. Centralized cache server keeps consolidated cache of all the nodes. Terracotta provides EHCache based distributed cache. In this blog I will provide how to configure Liferay to use Terracotta based distributed cache instead of EHCache based replicated cache.

Here are the steps to configure Liferay 6.1 CE server to use terracotta as caching engine.

Step 1 Download terracotta from http://terracotta.org/downloads/open-source/catalog URL and install the same in a a directory. We will refer this directory as TERRACOTTA_HOME in rest of the article.

Step 2 Download and install Liferay Portal CE GA2 in a directory. We will refer this directory as LIFERAY_HOME. You can download Liferay from this http://downloads.sourceforge.net/project/lportal/Liferay%20Portal/6.1.1%20GA2/liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558.zip URL.

Step 3 Now locate LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ tomcat-7.0.27\webapps\ROOT\WEB-INF\lib directory and delete following files.

    • ehcache*.jar
    • slf4j*.jar

Step 4 Locate the TERRACOTTA_HOME\ehcache\lib\ directory and copy the following JAR files to LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ tomcat-7.0.27\webapps\ROOT\WEB-INF\lib directory.

    • ehcache*.jar
    • slf4j*.jar

Step 5 Locate the TERRACOTTA_HOME\common directory and copy the following JAR file to LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ tomcat-7.0.27\webapps\ROOT\WEB-INF\lib directory.

    • terracotta-toolkit*.jar

Step 6 Create the terracotta-cache directory in the LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ tomcat-7.0.27\webapps\ROOT\WEB-INF\classes\ directory and create the hibernate-terracotta.xml file with following content:

Step 7 Create liferay-multi-vm-terracotta.xml file in LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ tomcat-7.0.27\webapps\ROOT\WEB-INF\classes\terracotta-cache directory and add following content in it:

Step 8 Add the following properties in portal-ext.properties file located in LIFERAY_HOME\liferay-portal-6.1.1-ce-ga2\ directory.

Step 9 Now start teracotta server first and then Liferay portal server.  If you are using clustered environment then you need to repeat step 2 to 8 for each node.

Summary

Liferay portal based solution in multi node cluster and expecting to have large data in cache then it is recommended to go with terracotta based distributed cache. Please refer my book Liferay Portal Performance Best Practices for such performance specific best practices.

Samir Bhatt

I am Samir Bhatt. I have more than 12 years of experience in IT Industry. I have been performing role of Software Architect since last four years. I am focused on open source technologies. I have specialized knowledge of Liferay Portal and has written two books on the subject. I lead Liferay practice in my organization with a strength of more than 140+ people. I am also Certified Liferay Trainer and conducted many public and private Liferay trainings across the world. Apart from Liferay I have good knowledge of Big Data technologies like MongoDB, Apache Hadoop. Throughout my carrier I worked on variety of technologies & Frameworks that includes JAVA, J2EE,Visual Basic, Oracle PLSQL, Spring Framework, Struts, Hibernate,Liferay, Pentaho and so on.

Comments

Atul Patel
Reply

Hi Samir.  Great blog.  On Step 5, the jar file name seems to be missing.

Samir Bhatt
Reply

Thanks Atul. I corrected the blog with jar file name.

Leave a comment

name

email (not published)

website

Current month ye@r day *