This article outlines Liferay configurations for distributed caching along with how to deploy custom tuning configurations. For cache tuning and finding optimal settings for a particular environment, please see the Ehcache website for documentation and support.
Resolution
How to Configure Distributed Caching
This article describes two approaches to replicate Ehcache for a clustered environment. The older approach utilizes Ehcache's default replication techniques. The newer approach utilizes the Liferay platform's built-in Cluster Link Replication. The Ehcache's default replication will have at least 100 more replication threads—after warm-up—over Liferay's Cluster Link Replication.
Cluster Link
The Liferay platform's Cluster Link Replication is available in 6.2.x EE, 6.1.x EE and 6.0 EE SP2. Evaluate if this technique of distributing the cache is better for your production environment than Ehcache's default cache replication techniques.
In 6.2.x EE and 6.1.x EE, set the following in portal-ext.properties:
cluster.link.enabled=true
ehcache.cluster.link.replication.enabled=true
Default Ehcache - RMI Replication Mechanism
Ehcache's default replication techniques are still available, especially for older versions of the portal that do not have the option of cluster link replication.
In 6.2.x EE and 6.1.x EE, set the following in portal-ext.properties:
cluster.link.enabled=true
ehcache.cluster.link.replication.enabled=false
How to Deploy the Cache Tuning Configurations to Liferay Portal
There are specific files that are necessary to deploy in order for your hibernate, multivm, or singlevm caches tuning configurations to be read by the portal. Users can configure the portal in one of two different ways:
- Deploying a custom plugin portlet with the configurations
- Configure the portal directly in the portal-ext.properties.
As mentioned above, cluster replication and cache tuning in 6.0 EE SP2, 6.1.x EE and above can be done via deployable plugins. The benefit is that administrators do not have to restart the server.
- Simply create a plugin and specify a file and path through the following properties in portlet.properties :
ehcache.multi.vm.config.location=ehcache.single.vm.config.location=net.sf.ehcache.configurationResourceName=Please see the above settings in portal.properties. Notice there are sample xml files which contain default tuning configurations. Copy the sample xml configurations into your custom xml file and make the appropriate modifications for your requirements (for example: Number of elements in cache, Expiry time for cache, Whether cache overflows to disk, etc). Be sure to specify the path to the custom xml file in the above settings (the custom xml should be located within the plugin's directory structure). The portal will load the files and configure the designated caches on deployment of the plugin.
More information about this cache tuning in User Guide's Modifying the Ehcache Settings With a Plugin section.
- The other method is to configure the portal directly. One must stop and restart the server for the settings to take effect. In 6.1.x EE and 6.2.x EE, specify a file and path through the following in portal-ext.properties
ehcache.multi.vm.config.location=ehcache.single.vm.config.location=net.sf.ehcache.configurationResourceName=Please see the above settings in portal.properties. Notice there are sample xml files which contain default tuning configurations. Copy the sample xml configurations into your custom xml file and make the appropriate modifications for your requirements (for example: Number of elements in cache, Expiry time for cache, Whether cache overflows to disk, etc). Be sure to specify the path to the custom xml file in the above settings (the custom xml files should be located in a location accessible by the portal). The portal will load the files and configure the designated caches on startup. More information about this cache tuning in User Guide's Modifying the Ehcache Settings Directly section.
The following information applies to legacy or end-of-life products. While this documentation is no longer maintained, the information may still be applicable for users on those product versions.
In 6.0 EE SP2, set the following in portal-ext.properties:
cluster.link.enabled=true ehcache.cluster.link.replication.enabled=true net.sf.ehcache.configurationResourceName=/ehcache/hibernate-clustered.xml ehcache.multi.vm.config.location=/ehcache/liferay-multi-vm-clustered.xml
In 6.0 EE SP1, set the following in portal-ext.properties:
cluster.link.enabled=true ehcache.cluster.link.replication.enabled=true net.sf.ehcache.configurationResourceName=/ehcache/hibernate-clusterlinked.xml ehcache.multi.vm.config.location=/ehcache/liferay-multi-vm-clusterlinked.xml
Note: Please download hibernate-clusterlinked.xml and liferay-multi-vm-clusterlinked.xml (unique for 6.0 EE SP1) from the Attachments section, which have been pre-configured to enable cluster link replication.
Additional Information
This article is an extension of the Liferay User Guide. You can find links in the Related Articles section above.
Tuning the cache is essential in leveraging the most out of Ehcache's benefits. Please refer to Ehcache's documentation for all the benefits and details about HOW TO tune the cache: Ehcache Documentation. For tuning in DXP, refer to Ehcache Configuration for DXP 7.0.
Attachments