InfoQ

News

A Real World Example of Using Terracotta: Clustering RIFE

Posted by Scott delap on May 30, 2007 09:29 AM

Community
Java
Topics
Clustering & Caching ,
Web Frameworks
Tags
Terracotta ,
RIFE
Terracotta's Jonas Bonér recently detailed how he and Geert Bevin (who was recently hired by Terracotta) clustered the RIFE web application framework. The article provides valuable insight into RIFE's continuations implementation as well as some of the challenges in clustering a non-trivial application like RIFE.

Bonér starts out by explaining how RIFE implements continuations:

RIFE’s continuations aims to make support for continuations in pure Java available as a general-purpose library ... It is using bytecode instrumentation (based on the ASM bytecode library) to generate code and redefine classes in order to implement this in the most effective way possible. It is not relying on Java serialization but is instead breaking down the object graph into primitives and stores the actual data on the execution stack (similar to the approach taken by Terracotta) ... The continuations are linked together in a tree structure which allows you to traverse to the different execution steps the way you want. This means that you can actually step back (and forward) in time, which is a very neat way of solving the browser back button problem - if used in the context of web applications.

Internally RIFE is storing its continuations in a regular java.util.HashMap.

The first obstacle they faced in clustering RIFE was to make access to this HashMap thread safe. The initial RIFE implementation was designed to only access the map using a thread for performance reasons. In moving to a clustered deployment there may be concurrent access from multiple JVM's.

The next challenged involved classloaders. As is typically the case with application servers and web frameworks, RIFE implements custom class loaders for a number of features which are not visible to Terracotta out of the box like the Java system class loader is:

The reason why Terracotta needs to be able to uniquely define a class loader is that it needs a way of, at any point in time and on an arbitrary cluster-node, retrieve the class loader instance that has loaded a specific class in order to maintain object identity across the cluster.

The biggest challenge Bonér and Bevin ran into however was clustering the dynamicity of the RIFE template engine. RIFE may generate classes on the fly at runtime if needed. This information needs to be replicated in the event that the node the class was created on crashes and subsequent request are redirected to another node. The solution proved to be a cluster wide bytecode repository implemented with a HashMap. The RIFE TemplateClassloader was then modified to reference this repository.

No comments

Reply

Exclusive Content

Book Except and Interview : Aptana RadRails, An IDE for Rails Development

Aptana RadRails: An IDE for Rails Development by Javier Ramírez discusses the latest Aptana RadRails IDE, a development environment for creating Ruby on Rails applications.

Fast Bytecodes for Funny Languages

Cliff Click discusses how to optimize generated bytecode for running on the JVM. Click analyzes and reports on several JVM languages and shows several places where they could increase performance.

Scott Ambler On Agile’s Present and Future

Scott Ambler, Practice Lead for Agile Development at IBM, speaks on the current status of the Agile community and practices having a look at the perspective of the Agile’s future.

Manager's Introduction to Test-Driven Development

Dave Nicolette and Karl Scotland try to introduce non-technical managers to one of the most popular Agile development techniques: Test-Driven Development (TDD).

Structured Event Streaming with Smooks

Smooks is best known for its transformation capabilities, but in this article Tom Fennelly describes how you can also use it for structured event streaming.

How to Work With Business Leaders to Manage Architectural Change

Successful architectures evolve over time to meet changing business requirements. Luke Hohmann presents how to collaborate with key members of your business to manage architectural changes.

Colors and the UI

In this article, Dr. Tobias Komischke explains how colors used in a GUI can influence our interaction with a computer and offers advice on using the appropriate colors for the interface.

Building your next service with the Atom Publishing Protocol

In his presentation, recorded at QCon San Francisco, MuleSource architect Dan Diephouse explores ways to use the Atom Publishing Protocol (AtomPub) when building services in a RESTful way.