Last updated by vjorrand 7 years ago
Terracotta is a Java infrastructure that allows you to scale your application by clustering JVMs.

Author: Vincent Jorrand (vjorrand at yahoo dot com)


  • Generation of a terracotta configuration file
  • Generation of terracotta enabled start up scripts for containers


grails install-plugin terracotta


  • Install the plugin
  • Run the start up script generation task
  • Run the terracotta configuration generation task
  • generate a war for the application and deploy in a container
  • start the terracotta server(s)
  • start the application servers


  • Generate<ContainerName>Script: Generate the start up script for an application server
  • GenerateTcConfig: Generate the tc-config.xml file for terracotta


Currently only 2 containers are supported: jboss and tomcat.

Edit to set the parameters for the start up scripts: The terracotta install directory on the target jboss or tomcat server

The path place where the tc.config.xml will be made available to on the servers (this plugin does not remote copy it you have to do that)


grails generate-jboss-scripts

Copy the generated scripts in the startup script folders of the containers. You will later start the containers using these scripts instead of standard ones.


Generates the tc-config.xml required to run a terracotta enabled container. It enables the clustering of all the domain classes defined in the project and allows to add any additional classes to be made clusterable by including a user defined xml segment. It also clusters the http sessions across the container instances for your application.

Edit to set the host names and ports for the terracotta servers to be used by the application.

Edit CustomIncludes.xml to specify any additional terracotta include rules required by your application.


grails generate-tc-config

Copy the generated file on each container server, in the location specified when generating the container start up scripts.

Running the Clustered Application

Deploy your application on all the container instances. Start the terracotta server(s) Start the containers using the generated start up scripts. (Note that you will need a form of load balancing to witness the effects of the clustering, I used Apache with mod_jk)

Fun Note

Start one only one node of your cluster. Start a session (log in your app, ...). Stop that server instance, then start another one. Continue using your application without losing your session!

Looking Ahead

Future enhancements include support for more containers (easy), and support for running terracotta in development mode (more complex).