« March 2008 | Main | May 2008 »

April 2008 Archives

April 1, 2008

Speed of Light shattered

Today is a great day in the history of the world.

Terracotta announces that we have taken our software's infinite linear scalability to the stars. We have built a light-bending server that can accelerate a small space vessel well past the speed of light, and we tested it in conjunction with the folks behind SpaceShipOne.

We call it SpaceShipTerracotta.

Ari Zilka said, "Last night, I wanted to go to Mars for dinner. I ended up 2 galaxies away before we managed to stop." Zilka continued, "while we have a few bugs to iron out, this is a very exciting invention and we are very pleased with our progress thus far."

NASA Administrator Michael Griffin was quoted as saying, "Terracotta continues to push the technology envelope. First they built JVM-level clustering. Now they passed the speed of light. Those guys are hard to keep up with!"

Terracotta says that its technology will soon be bundled with offerings from Boeing and Airbus. With the Terracotta server onboard, a non-stop flight from Los Angeles to New York (2451 statute miles) would travel at approximately 188,000 miles per second, reaching the other side of the continent in 0.01 seconds.

Mr. Zilka said, "The longest part of your travel is soon to be the time it takes to pack for the trip."

Just kidding. (SpaceShipOne, Nasa, Mr. Griffin, Boeing, and Airbus names used without permission as this is just an April Fools joke.)

April 10, 2008

Stuff I found, or more accurately, stuff that found me...

Compass: scalable Lucene-based index / search library. I really like Compass quite a bit more than Lucene, itself. Definitely performs better on top of Terracotta than our own Lucene Integration Module. If you arelooking at or using Lucene, and want shared indexes across JVMs, Compass is the way to go. Check it out at http://www.kimchy.org/compasslucene-terracotta-integration/

Semispaces: Javaspaces with clustering built using Terracotta. If you want spaces and the Terracotta runtime at the same time, well, now its available. Its OSS (Apache 2) so you can have a completely OSS stack for this use case, which is kewl. Find it at http://www.dynamicus.org/semispace/

ODAL: Objective database abstraction layer. This one sounds interesting. O/R-mapping. Data loading. Cache-based querying. Basically, a full-featured interface to and abstraction of the database. I definitely need to dig in a bit more here. The instructions for clustering the framework with Terracotta are at http://odal.sourceforge.net/odal-guide.xhtml#1.9.18.1.Terracotta%20Cache%20Clustering|outline

I guess the Terracotta Integration Module concept is working well. OSGi is definitely serving its purpose. That's for sure. Semispaces and ODAL did all the integration work with Terracotta and the bundling work on their own. BTW, I just finished reviewing the chapter on building integration modules that Alex Miller wrote. I think the book chapter is way better than the website documentation linked above. Great work Alex!

Anyways, more on Compass in a separate post.

Cheers,

--Ari

April 14, 2008

OSGi delivering on the promise

I just spent the day at TheServerside Symposium in Las Vegas watching integration between 2 frameworks. Once the integration was complete, it was time to bundle the integration into a nice consumable kit. The question was, how? The answer was OSGi.

We use OSGi to allow people to:
1. bundle up some config that ends up inlined / included in another config file (nesting and all the goodness included)

2. code insertion / introduction where you add methods, interfaces, and more to existing and already compiled classes.

3. Code replacement where you change / overload methods, classes, etc.

Say, for example, you want to build a simple included bit of config. You need to write a file called terracotta.xml which is a fragment of a tc-config file. Then you need to set up the manifest for OSGI bundle activation as follows (taken from http://www.terracotta.org):
Bundle-Description: MyApp/MyFramework Cluster Configuration
Bundle-DocURL: http://www.myorg.org/doc/terracotta-integration-module/
Bundle-Name: Terracotta integration module for MyApp/MyFramework
Bundle-SymbolicName: org.myorg.myapp.integration_module
Bundle-Vendor: MyOrg, Inc.
Bundle-Version: 1.0

Note that you can just use our maven tim (terracotta integration module) archetype to stub out a new module that you can then add files to as appropriate.

What's exciting about OSGi to me and what I think makes it work really well for us is not that we can augment apps and frameworks at runtime with what appears to be 3 lines of xml:



What excites me is that people can use OSGi to build modules that just appear to be jars to the untrained eye. I didn't think about this when first watching the team integrate OSGi. We knew we wanted to use OSGi to give ourselves hot-pluggable modules. We just didn't think too much about the resulting jar still being a proper jar. Compass, for example, has always shipped as a clean and simple jar library to be integrated and linked through the classpath. It is still the same, but if a terracotta installation is present and an appropriate stanza is included, your Compass installation will be clustered. Compass is a Terracotta Integration Module.

Never thought about it but OSGi doesn't just give us hot-pluggable modules. It gives you, the user, the ability to write a library that auto-clusters in the presence of the clustered runtime yet is a simple jar to your development team.

I love it.

April 15, 2008

How to profile locks with Terracotta (stay tuned)

I am going to write a blog about how to use our lock profiler to find deadlocks and other locking hotspots. A forum user just expressed that he has no idea how to do it, so it seems to be something most folks don't realize is there.

Stay tuned...

--Ari

April 17, 2008

Lock profiling across JVMs in a cluster

I've wanted to write this for a while. I finally just sat down and went ahead and wrote it.

First, the concept--visualization tools for building apps. Sun is building the VisualVM. We are building a suite of tools we call the Visualization Tools. Cluster Visualization. Snapshot Visualization. Both runtime GUI graphs and snapshots stored in a DB for offline view via GUI graphs. Anyways, let me explain why visualization is important.

Think back to your Calculus 1A class. (You may have been in high school, college, or maybe grade school if you are mathematically inclined :P.) I took lots of math in my life. But some things stick better than others. My favorite example is integrals / integration. I think we all remember that integrals are conceptually defined as "the area under the curve between two points a and b." But, while I remember that and I can still do integration (and even differential equations) I still need to look up the process for integration by parts. Even worse, I never remember the integral of tan (x) dx. Why is this?

Well, some of think in visual terms and others in textual terms. 3-D vs. 2-D. Essentially, people think in different ways yet integrals are orthogonal to all this. We can remember an integral as the area under a curve as defined by some equation simply because it is a concept. We cannot remember the integral of tan (x) dx because it is a rote-memorized formula. Only those of us who use such equations day to day can remember such things. At least I personally believe this is true. (As an example, my brother has many advanced engineering degrees and he can rattle off all these equations at any time because of deeper use in his day to day.)

In Java there is a ton of coverage in the press about multi-threaded programming and how multi-core is taking us in new uncharted directions. I think what makes multi-threading difficult is not the concepts. Everyone I speak with who codes Java knows what a thread is and what synchronized{} is for sure. They do not know, however how to avoid deadlocks in their design nor how to track them down reliably. It is a familiarity thing more than a conceptual challenge.

This is why we built visualization tools: to take the notion of locking, lock tuning (striping and the like), and deadlocks from an experienced technician's hands to a conceptual thing we can all work with. Let's look at an example:

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.BrokenBarrierException;

class Main {
static AtomicInteger a = new AtomicInteger( 1000 );
static AtomicInteger b = new AtomicInteger( 1 );
static CyclicBarrier barrier = new CyclicBarrier( 2 );

public static void main( String args[ ] ) {
AtomicInteger ref1, ref2;

System.out.println( "Waiting for my partner..." );
try {
barrier.await( );
} catch( BrokenBarrierException e ) {
System.err.println( e.getMessage( ) );
} catch( InterruptedException e ) {
System.err.println( e.getMessage( ) );
}


if( args[ 0 ].equals( "a_first" ) ) {
ref1 = a;
ref2 = b;
} else {
ref1 = b;
ref2 = a;
}

synchronized( ref1 ) {
System.out.println( "ref1 =[" + ref1.getAndIncrement() + "]. Sleeping." );
try {
Thread.sleep( 2000 );
} catch( InterruptedException e ) {
System.err.println(e.getMessage());
}
synchronized( ref2 ) {
System.out.println( "ref2 =[" + ref2.getAndIncrement() + "]. Sleeping." );
}
}
}
}



The Terracotta config to cluster this looks like the following:



<instrumented-classes>
<include>
<class-expression>*..*</class-expression>
</include>
</instrumented-classes>

<roots>
<root>
<field-name>Main.a</field-name>
</root>
<root>
<field-name>Main.b</field-name>
</root>
<root>
<field-name>Main.barrier</field-name>
</root>
</roots>

<locks>
<autolock>
<method-expression>* *..*.*(..)>/method-expression<
</autolock>
</locks>


Now, the CyclicBarrier in there guarantees that when we run Main, 2 JVMs must start up before we go racing for locks. Note that the AtomicIntegers are locked in an order defined on the command line. Passing "a_first" to Main will cause the order of lock acquisition to be:
1. Lock A
2. Lock B
3. Unlock B
4. Unlock A

Whereas passing "b_first" to Main will cause the order to be:
1. Lock B
2. Lock A
3. Unlock A
4. Unlock B

Essentially, we have nested locks in inverted order--a classic and simple deadlock. The Terracotta console will show this to us. Let's go ahead and run the application:

$TC_HOME/bin/dso-java.sh Main a_first in one window
$_TC_HOME/bin/dso-java.sh Main b_first in a second window.

The two JVMs will each print

Waiting for my partner...

Then they will increment one reference and print it before getting trapped in the deadlock.

ref1 =[1000]. Sleeping.

The only way to get the program to print ref2 would be to kill one of the JVMs at this point. Kill both now as we will need to rerun everything with lock profiling enabled inside Terracotta. Now start:

$TC_HOME/bin/admin.sh

Start the lock profiler tool in the admin console. Here's a screen shot in case you can't find how to do it:

LockProfiler.png
(click the image to enlarge)


Make sure you set the stack trace depth to 10, and that you click "start" as shown in the image above. Now run both programs. Come back to this profiling tool and continually hit "refresh" in the lock profiler. I got the following interesting results after a few seconds, and then a minute later. Note that I double-clicked the column named "Average Held Time" to sort by that column. Double click it again if it is sorted min-to-max (you want max-to-min order).

SortingLocks.png
(click the image to enlarge)


Killing the "b_first" JVM and returning to the console to refresh the display showed the 60 second wait time for one thread and vice versa.

BlockingEachOther.png
(click the image to enlarge)

Now I took the lock ID, in this case Terracotta gave it 1001, and I went back to "clients" tab to see the stack traces and find the different paths each JVM had taken to get to this lock. The answer was at Main.java, code lines 31 and 38.

CodeLocations.png
(click the image to enlarge)

Now go back to your editor and look at Main.java. Those 2 lines of code are the lines where the synchronized{} calls are in inverse order at runtime. The tool took me straight to the lines of code that were the problem!!!

Trivial example, true. Powerful tool, nonetheless.

--Ari


April 23, 2008

The Book Is Almost Done

Bleery eyed. Near zero sleep in days. Orion helping out. Even my wife is helping out with editing.

But, the good news is 10 of 12 chapters are good to go. Get your copy now.

I think if you need help understanding Terracotta this is a good tool. And if you want to become a power user, this book will also get you across the line, helping you to:

1. Build your own integration modules (just like our EHCache or Hibernate modules)
2. Visualize and tune your applications
3. Build multi-threaded / multi-JVM apps
4. Build massive grids running on Terracotta.

Get your copy now. Bring it with you to JavaOne and I will answer any questions you have at our booth.


Amazon has apparently sold a thousand copies based purely on pre-order [a little birdie told me]. So exciting.

Cheers,

--Ari

April 25, 2008

In London? Wanna get "In the Brain..."?

Not sure that anyone should get inside my brain, but we are going to try anyhow. June 24th, in London at Skills Matter. I think we are going to follow up that week with a 2 day in depth training hosted by me and Orion Letizi (Terracotta co-founder).

I am really looking forward to spending time with people. I love to watch their faces when their POJO apps start doing multi-JVM interactions in place of multi-threaded actions. Terracotta gives people the confidence to write apps with SEDA, master / worker, and other asynchronous frameworks that they would otherwise avoid. Terracotta also gives people a platform for taking existing JSE / JEE apps and scaling those without much new work / redevelopment. Its energizing to see people get excited after using the demos, samples, and especially after having written their first TC-config file for their own app.

See you there!!!

--Ari


April 27, 2008

Resin on Terracotta, anyone?

Emil Ong introduced himself to us at Terracotta a couple of months ago. We had a short conversation and he mentioned he was going to start Terracotta integration shortly. I haven't heard much from Emil since; just a polite word here or there like, "everything's fine." I was just about to reach out and see if he needed any help when I found this.

Now you can run Resin on Terracotta for:

  • clustered servlet session
  • straight DSO / clustered POJO
  • PHP-based apps

Everyone, go ahead and check it out.

NICELY DONE Emil!!!

--Ari

April 29, 2008

Control my talk at JavaOne

I am speaking again this year at JavaOne. I am trying something bold. The original plan was to do this with Brian Goetz but he has 5 talks so I will go it alone. I have a poorly performing application that I am going to tune using visualization techniques, all live.

It just occurred to me, however, that you may have an app you want me to use. If you do, comment here and let me know what you are thinking. I will of course need time to get your app, understand it, make sure I can cluster it with Terracotta and make it go faster using visualization tools and techniques.

Ideally, it is a small sample. I can't be starting MySQL instances and such while speaking to the audience.

BTW, I will be using Terracotta 2.6 which is brand new. This whole thing could go down in flames...and I mean 4 alarm fire.

So, lay it on me man!

--Ari

About April 2008

This page contains all entries posted to POJO Mojo in April 2008. They are listed from oldest to newest.

March 2008 is the previous archive.

May 2008 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34