In the comments to my post about what Terracotta is not, Jay Meyer wrote:
[Terracotta] is so disruptive that an application architect really needs to sit down and assume Terracotta is available and then design a real killer app.
That comment has been tumbling around in my head for the last month. I think Jay makes a good point. On the one hand, lots of people are using Terracotta for a bunch of different things. On the other hand, we do tend to struggle getting people to think in the Terracotta way and not slide back into bad old habits using the fine surgical instrument of Terracotta as a hammer (we have a running joke inside Terracotta that every use case looks like "distributed caching" because the EHCache integration module is so easy to use).
With that in mind, I've recently noticed a couple of interesting and creative uses of Terracotta. They may or may not be the "killer app", but they do really take advantage of Terracotta's unique features:
In the first use case, JR Boyens describes how they used Terracotta for managing configuration across many JVMs. What I really like about this is how Terracotta takes a problem that should be simple (configuration) but is ridiculously hard in a distributed computing environment and reduces it back to its simplest essence.
There's a lot I like about the second use-case presented by Mark Turansky (and I'm really excited about the case study Mark is working on), but two things stand out in the particular blog post mentioned above. The first is using Terracotta to simplify making cluster-wide changes to data that affects enterprise-wide application behavior (this is starting to look like a theme):
For example, we offer a REST API to abort a pending message (such as http://ourendpoint/message/abort/abcdefg-the-guid-wxyz). The easiest way we found to tell the entire bus to disregard this message was to flip the bit on the message itself.
—Mark Turansky
Using Terracotta, to change the status on the message in response to a REST call is as simple as looking it up in a local data structure (like a Map), then flipping the status on the message object. Without using Terracotta to do this, you have to go through a ton of work (probably involving RMI or a database lookup or who knows what) to figure out in which nodes in your distributed computing environment the message is currently resident. Then, once you've found the message, you have to somehow deal with the concurrency issues of changing its status across multiple machines while it is potentially being processed.
Again, Terracotta takes a problem that should be simple but is hard in a distributed context and reduces it back to the familiar simplicity of a plain Java program.
The second thing I like about Mark's use-case is a side effect of Terracotta hiding the complexity of distributed computing: the architecture works just as well in a single JVM as it does across many JVMs. Removing infrastructure concerns from application code makes working on that application so much easier. Terracotta lets you work at the unit level without having to struggle with setting up a distributed computing environment.
If you were using a database, for example, to coordinate this message activity, you would be forced to run that database in order to work on a unit-level feature. Using Terracotta to take care of infrastructure concerns lets you work on a unit-level with Terracotta off so you can express the problem in pure Java. We've had users remove as much as 30% of their application code by switching to Terracotta.
This has a direct impact on code quality and developer productivity. Since there is a direct relationship between the number of lines of code and the number of bugs in an application, removing 30% of your application code should, at a stroke, remove a significant number of bugs. Developer productivity goes up because you don't have to spend time setting up and debugging interaction with databases and other fiddly parts of a distributed application environment just to work on a unit level feature. That gives you a lot more time to work on features.
By factoring out the infrastructure, Terracotta lets you truly work at the unit level and concentrate on getting the code logic right. To put it another (much more abstract) way, Terracotta lets you concentrate on semantics—on expressing what you mean—rather than on syntax—the mechanics underlying the expression.