Quick look at Terracotta - source enthusiasm

Friday, November 9, 2007

Quick look at Terracotta

Terracotta is a cool open source clustering technology for Java. Using Terracotta you can easy share objects across JVMs. You can easy write and test your application running in a single JVM. And after that make application scalable and highly available and run on more than one JVM.
Terracotta allows threads in a cluster of JVMs to interact with each other across JVM boundaries using the same built-in JVM facilities extended to have a cluster-wide meaning. These clustering capabilities are injected into the bytecode of the application classes at runtime, so there is no need to code to a special clustering API.
What does DSO (distributed shared objects) do?
Terracotta DSO extends the Java Memory model from one to multiple JVMs. It layers in at the bytecode level and requires no Java API. It maintains object identity, wait, notify and synchronize and creates a virtual heap for the parts of your object graph that you mark as in need of sharing. You mark a part of your application as in need of sharing by specifying Roots.
You can shared variable in class, mark fields as transient if you don't want them shared or just lock them. The main feature is that you don't need write specific code and can clustered any stand alone application. Creating a tc-config.xml file that defined all roots and fields. You can easy clustered you application, with out any code modifications. If you avoid writing XML by hand use the Terracotta DSO EclipsePlugin. Once the configuration is complete, running the application in a cluster can be done from the Eclipse "Run As -> Terracotta DSO Apllication" or from the command line using a script called dso-java.bat instead of starting it with regular Java. Here you can see how Terracotta work. For detail information start the tc-admin console. So as we can see at diagram, Application should have configuration file and server. The first step is to start the Terracotta server. Once the server is started, the instance of your application can be started. Every new instance of application work with server. Terracotta uses a client/server architecture where the JVMs running the clustered application connect to a central Terracotta server at startup.
DSO maintains a virtual heap so only the parts of the object graph that are needed in each JVM are actually there. As your code reaches into your object graph DSO will dynamically start pulling in the needed data. This allows one to have heaps that are much bigger than your memory space. Of course if one is cycling through all the data all the time one will end up with thrashing but if what you are really doing is having various JVM's acting on some part of the data for some part of the time this is a really useful feature.
Official Terracotta home page

No comments: