<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>POJO Mojo</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/" />
   <link rel="self" type="application/atom+xml" href="http://blog.terracottatech.com/atom.xml" />
   <id>tag:blog.terracottatech.com,2008://1</id>
   <updated>2008-06-23T23:20:02Z</updated>
   <subtitle>Talk about Terracotta</subtitle>
   <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.34</generator>

<entry>
   <title>Avoiding the Palm / Treo Mistake</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/avoiding_the_palm_treo_mistake.html" />
   <id>tag:blog.terracottatech.com,2008://1.117</id>
   
   <published>2008-06-23T23:09:09Z</published>
   <updated>2008-06-23T23:20:02Z</updated>
   
   <summary>I was thinking on the flight back from Scotland to London today (mostly because several of us were geeking out about our phones and the OSes on those phones): Palm Treo almost cornered the market on smartphones / PDAs. What...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[I was thinking on the flight back from Scotland to London today (mostly because several of us were geeking out about our phones and the OSes on those phones):

<blockquote>Palm Treo almost cornered the market on smartphones / PDAs.  What happened?  Well, apart from the bulkiness and slowness of the physical device, the OS was unstable.  I remember that it couldn't even get a semaphore implemented in a stable fashion.  My Treo would regularly lock up trying to pull mail while I was in the middle of a phone conversation.  The radio can only be used for data or voice protocol so lock the radio out to protect from confusing the device.  But they couldn't seem to get it right.
</blockquote>

What killed Treo in my opinion was largely its instability.  I think it is safe to assume Palm had a hardcore QA team.  After all they were building devices, OSes, and apps at some point in their past.  So what went wrong?  The wrong type of QA.  Concurrent applications.  High stress (lots of email in memory). Slow network connectivity.  While I know that Palm regularly sent users into the field with pre-release versions of systems, a more explicit framework was required.

Clustered application QA is a hot-button issue for us here at Terracotta.  I expect to put a few documents together to help explain things but for now, here's a quick set of rules:

1. functionally QA without Terracotta in the mix (since it is transparent)
2. Then functionally QA clustering with Terracotta in the mix.  By example: if you have a web-based workflow, run through the functional flow on a single JVM.  Then rerun the flow while proxying through a round-robin load balancer across 4 JVMs.  Then do it with multiple simulated users.  This will confirm your business data is coherent and shared. (Yes, I have seen use cases where the data is not shared even though the application team integrated Terracotta into the application.)
3. Stress test at 1X, 2X, 5X, 10X, and 100X your production workload.  Can't afford a production scale stress lab?  Then push a scaled down cluster to the same TPS as production.  Example: if production sees 10 TPS per server at peak, then test to 1000TPS per server, even if you have only 2 servers in rotation.  Its not perfect but it will teach you a lot.

This should help you to get started producing stable clustered applications over and over.  It will make your boss and the line of business to which he and you are accountable very happy.  BTW, these rules have nothing to do with Terracotta.  They are just good practice.  In general, I also recommend something our head of engineering always reminds us to do.  And that is to stay high level.  Don't only worry about whitebox QA.  Think of user stories and scenarios and walk your application through the scenario, from top to bottom.

Let me know what rules you adhere to to avoid the Treo mistake.]]>
      
   </content>
</entry>
<entry>
   <title>The Terracotta Book is in the Mail</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/the_terracotta_book_is_in_the.html" />
   <id>tag:blog.terracottatech.com,2008://1.116</id>
   
   <published>2008-06-20T14:42:15Z</published>
   <updated>2008-06-20T14:44:59Z</updated>
   
   <summary>The following items have been shipped to you by Amazon.com: --------------------------------------------------------------------- Qty Item Price Shipped Subtotal --------------------------------------------------------------------- Amazon.com items (Sold by Amazon.com, LLC): 1 The Definitive Guide to Te... $29.69 1 $29.69 Shipped via USPS (estimated arrival date: 26-June-2008). Get...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[The following items have been shipped to you by Amazon.com: 
---------------------------------------------------------------------
Qty      Item                           Price  Shipped  Subtotal
---------------------------------------------------------------------
Amazon.com items (Sold by Amazon.com, LLC):
  1     The Definitive Guide to Te...   $29.69      1   $29.69

Shipped via USPS (estimated arrival date: 26-June-2008).

<a href="http://www.amazon.com/Definitive-Guide-Terracotta-Hibernate-Scalability/dp/1590599861/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1213969418&sr=8-1">Get it for yourself.</a>]]>
      
   </content>
</entry>
<entry>
   <title>Second book on Terracotta</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/second_book_on_terracotta.html" />
   <id>tag:blog.terracottatech.com,2008://1.115</id>
   
   <published>2008-06-20T05:34:28Z</published>
   <updated>2008-06-20T05:35:27Z</updated>
   
   <summary>Time to get started on the next book. Steve Harris (our head of engineering) had a good idea. &quot;Clustered Design Patterns.&quot; I think he is just the man to help write it too. Any interest out there in such a...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      Time to get started on the next book.  Steve Harris (our head of engineering) had a good idea.  &quot;Clustered Design Patterns.&quot;  I think he is just the man to help write it too.  Any interest out there in such a book?

--Ari
      
   </content>
</entry>
<entry>
   <title>Caching Doesn&apos;t Work</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/caching_doesnt_work.html" />
   <id>tag:blog.terracottatech.com,2008://1.114</id>
   
   <published>2008-06-18T21:01:42Z</published>
   <updated>2008-06-18T21:25:43Z</updated>
   
   <summary>I just finished a discussion where someone asserted that developers can be frustrating because they make blanket assertions such as &quot;caching doesn&apos;t work&quot; or &quot;the only thing that works for storage is the database.&quot; Of course, it is not in...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      I just finished a discussion where someone asserted that developers can be frustrating because they make blanket assertions such as &quot;caching doesn&apos;t work&quot; or &quot;the only thing that works for storage is the database.&quot;  Of course, it is not in my best interest to agree with these statements, but I can see where they are coming from.

Here&apos;s the problem though.  I have seen several use cases where people take streams of data (gigabytes an hour), shove the streams into Oracle and then want to report on random slices of the stream.  

This is tough stuff.  It is tough because the database can barely keep up with the insert volumes if at all.  Then the ad hoc query and reporting workload breaks the database&apos;s back.  

So people pick up their head and say, &quot;cache the queries.&quot;  Problem is, you end up with what I call a &quot;long tail&quot; where every query is somewhat different and thus, a long tail of seemingly one-off queries misses the cache and ends up hitting the db.

Solution?  Process the data in-stream.  Pre-generate the object oriented representation using Terracotta in memory (you get access to lots of memory outside the scope of your Java heap and you get durability in case of system crash--everything is on disk). Essentially, if all your data is made up of events and you have to analyze those events, might as well do the analysis as the data is flowing by and not do analysis just when the user pulls the report.

The difference is that reporting on data stored in Oracle can be cached but the cache is only useful if the same analysis is executed twice (exact same SQL).  Pre-analyzing the data and storing the summaries / roll-ups (parse tree, if you will) and sharing those is not about caching.  It can handle much higher rates of change because the ad hoc analysis workload is eliminated. Furthermore, you can store a fine-grained analytical tree of data that can support many ad hoc types of queries from memory.

So, while it is ludicrous to assert that a rule might exist where caching does not work, it is just as ludicrous to attempt to cache a long tail problem.  Go at it another way.

--Ari
      
   </content>
</entry>
<entry>
   <title>When requirements can lead you astray</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/when_requirements_can_lead_you.html" />
   <id>tag:blog.terracottatech.com,2008://1.113</id>
   
   <published>2008-06-13T16:27:29Z</published>
   <updated>2008-06-13T16:39:45Z</updated>
   
   <summary>First an aside: I was reading European Car (June 2008) magazine this morning. Okay. Okay. I am an über geek. I don&apos;t just geek on software and infrastructure but on all things engineering. I admit it. Anyways, the contributing editor&apos;s...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      First an aside:

I was reading European Car (June 2008) magazine this morning.  Okay.  Okay.  I am an über geek.  I don&apos;t just geek on software and infrastructure but on all things engineering.  I admit it.

Anyways, the contributing editor&apos;s letter was all about top-down vs. bottom-up design.  He thought till last week that auto-driving highways is a near impossibility for now because we need perfectly precise GPS, huge compute horsepower to keep track of all the cars everywhere in real time, etc.  He then drove a BMW that was using radar and cameras to follow the car in front (this car is a production car available at your local BMW dealer...nothing secret and experimental).  He realized immediately that the cars can work in a mesh of self-piloting little brains all working with a few inputs and internally handling special cases like emergency stop, etc. all on their own.  

I found it relevant to software design from a requirements gathering perspective.  If the requirement from the business is stated as &quot;make all the cars drive on their own from Los Angeles to Las Vegas and make sure no one gets killed,&quot; how are we as engineers supposed to know that we should use a centralized or decentralized brain for the implementation?  The editor called this a top-down vs. bottom-up sort of thing but he was wrong.  Its not about agile, top-down, requirements first, or anything else.  Its about good engineering.  One engineer can take the requirement and come up with a centralized approach while another can do exactly the opposite.

The point?  Yesterday I got a requirement from a customer to store 1TB of data churning every 3 hours and then enable users to report on it, generating ad hoc queries.  So, I dug around a bit and figured out that (a) the reports are canned and (b) the reports are all about statistical analysis of the data (mins, maxes, averages, what have you).  So we flipped the requirements to packing the data into report-ready form sort of like cubing in an OLAP system.  We then did away with the raw data saying to the users that if you install a new reporting dimension into the system, it will be ready to view 3 hours later after it has been populated.

Exact same problem as the car-self-driving thing.  User asked, &quot;how do I show I retain a window of 3 hours of data for users to report against.&quot;  The answer turns out to be &quot;generate the reports in stream as the data is flowing by.  Then forget about the raw data.&quot;

The punchline: the user was struggling with a distributed in-memory SQL engine on top of Terracotta when none was required.  

Don&apos;t jump to quickly to design and implementation.  IMHO, it is important to keep asking questions long after you think you understand the use case.  Poke at all the requirements.  And if you want a more formal framework, I would say, if you know what is hard and easy based on lots of QA and stress testing and performance analysis, use that info to poke and prod on the requirements.  Cast a business problem toward your strengths, not your weaknesses, and never assume that the business cannot relax a rule or two.

--Ari
      
   </content>
</entry>
<entry>
   <title>The Book is Done!</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/06/the_book_is_done.html" />
   <id>tag:blog.terracottatech.com,2008://1.112</id>
   
   <published>2008-06-01T12:37:18Z</published>
   <updated>2008-06-01T12:38:14Z</updated>
   
   <summary>From the publisher... Hi guys: I wanted to let you know that your book shipped today. It&apos;s technically a day late but I talked our Manufacturing Director into counting it as still being on time for our Friday ship date....</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      From the publisher...

Hi guys:
I wanted to let you know that your book shipped today. It&apos;s technically a
day late but I talked our Manufacturing Director into counting it as still
being on time for our Friday ship date. I know this was a long haul, so
congratulations and thank you very much for your efforts.

Your book&apos;s official publication date is June 23rd, so I expect you&apos;ll
receive your [author] copies by the end of June or in the first week of July.

Thanks again and safe travels in the coming months.
Apress team.
      
   </content>
</entry>
<entry>
   <title>My Talk is being repeated tomorrow</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/05/my_talk_is_being_repeated_tomo.html" />
   <id>tag:blog.terracottatech.com,2008://1.111</id>
   
   <published>2008-05-09T04:01:11Z</published>
   <updated>2008-05-09T04:06:15Z</updated>
   
   <summary>Missed my talk on Tuesday? Sun has asked me to repeat it tomorrow. Room #300 at 2:50 pm. Yes I know its the last day and you want to go see the beautiful places in and around S.F., but Tuesday&apos;s...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[Missed <a href="http://blog.terracottatech.com/2008/04/control_my_talk_at_javaone.html">my talk on Tuesday</a>?  Sun has asked me to repeat it tomorrow.  Room #300 at 2:50 pm.  Yes I know its the last day and you want to go see the beautiful places in and around S.F., but Tuesday's crowd had so much fun.  We did a "choose your own adventure" style session.  I explain the application I have built.  We then use tools and analysis together to tune the application's performance.  By default, the app does a big processing task in 80 seconds.  The Tuesday audience and I got it down to 4.4 seconds.  I personally came up with an approach that runs in 1.5 seconds.  

Come by tomorrow.  Let's see what you can do :)

--Ari
]]>
      
   </content>
</entry>
<entry>
   <title>Twitter is fascinating.  Helps me learn about my project.</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/05/twitter_is_fascinating_helps_m.html" />
   <id>tag:blog.terracottatech.com,2008://1.110</id>
   
   <published>2008-05-07T05:12:15Z</published>
   <updated>2008-05-07T05:27:49Z</updated>
   
   <summary>Have you looked at Twitter? I am addicted. The interesting thing is that David Pollack (seen on this blog commenting, after having been given unclear info about TC in the past) and I played with &quot;the Twitter problem&quot; in a...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[Have you looked at <a href="www.twitter.com">Twitter</a>?  I am addicted.  The interesting thing is that David Pollack (seen on this blog commenting, after having been given unclear info about TC in the past) and I played with "the Twitter problem" in a Terracotta context / vacuum.

We learned something interesting together: Terracotta is core infrastructure.  It can be used in many ways, but not all will work as well as others.  

As an example (without going into details about Twitter since I know nothing about it, and we were just using it as a framework for discussion--check Twitter out for yourself and figure out how this all applies):

1. David thought that Terracotta should be used for messaging between some sort of node construct.
2. A few people want to use TC for messaging
3. I don't think TC should be used for messaging unless you want durable POJO-based messaging w/o any other infrastructure.  Specifically, if you have clustered objects using TC and you need some messaging to signal and pass control amongst those already-clustered JVMs, go for it.  But keep in mind TC is not a message bus.
4. Anyways, the more apropos use of Terracotta in a giant coordinated grid IMO might be to use point-to-point communication between Scala actors in the grid.  Terracotta can then be used as an actor<->JVM lookup table that tells you where actors can be found at any point in time.  Actors can then be migrated amongst nodes in real time because the lookup table is cluster-wide coherent at all times.
5. When the JVMs where actors are hosted crash, Terracotta's JMX-based cluster membership notifications can be leveraged to dynamically migrate actors in the grid.

The key: just because you have a hammer, not everything is a nail.  I think it is incumbent upon us at Terracotta to make nails versus screws very clear to our users.   I am going to plumb up Scala, Apache Qpid, and Terracotta in my copious spare time.

Stay tuned. 

--Ari]]>
      
   </content>
</entry>
<entry>
   <title>All set for JavaOne</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/05/all_set_for_javaone.html" />
   <id>tag:blog.terracottatech.com,2008://1.109</id>
   
   <published>2008-05-05T16:44:40Z</published>
   <updated>2008-05-05T16:48:21Z</updated>
   
   <summary>You in town for JavaOne? Head to my talk if you can. Its on the 1st day, which is kinda of good because I get it over with quickly. But, its on the 1st day so many people will not...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[You in town for JavaOne?  <a href="https://www28.cplan.com/cc191/sessions_catalog.jsp?ilc=191-1&ilg=english&isort=&isort_type=&is=yes&icriteria1=+&icriteria2=+&icriteria9=TS-7735&icriteria8=&icriteria3=">Head to my talk if you can.</a>  Its on the 1st day, which is kinda of good because I get it over with quickly.  But, its on the 1st day so many people will not have acclimated to the conference.

The important thing is the "broken application" which we are going to fix is pretty kewl.  It is multi-threaded, does lots of work and I boil down the problems with it to plain English for the audience.  Note that there are 2 parts where you the audience get to decide which way I fix the app.  We shall see together if the fixes will help.  

Cya there!

--Ari]]>
      
   </content>
</entry>
<entry>
   <title>Control my talk at JavaOne</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/control_my_talk_at_javaone.html" />
   <id>tag:blog.terracottatech.com,2008://1.107</id>
   
   <published>2008-04-30T03:20:25Z</published>
   <updated>2008-04-30T03:28:02Z</updated>
   
   <summary>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...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[<a href="https://www28.cplan.com/cc191/sessions_catalog.jsp?ilc=191-1&ilg=english&isort=&isort_type=&is=yes&icriteria1=+&icriteria2=+&icriteria9=&icriteria8=terracott&icriteria3=">I am speaking again this year at JavaOne</a>.  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 <a href="http://www.terracotta.org/confluence/display/orgsite/Terracotta+2.6+Landing">visualization techniques</a>, all <strong><em><u>live</u></em></strong>.

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

]]>
      
   </content>
</entry>
<entry>
   <title>Resin on Terracotta, anyone?</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/resin_on_terracotta_anyone_1.html" />
   <id>tag:blog.terracottatech.com,2008://1.106</id>
   
   <published>2008-04-27T16:49:14Z</published>
   <updated>2008-04-27T16:55:02Z</updated>
   
   <summary>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&apos;t heard much from Emil since; just a polite word...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[<a href="http://blog.caucho.com/">Emil Ong</a> 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 <a href="http://wiki.caucho.com/Terracotta">found this</a>.

Now you can run Resin on Terracotta for:
<ul><li> clustered servlet session</li><li> straight DSO / clustered POJO</li><li> PHP-based apps</li></ul>

Everyone, go ahead and check it out.

NICELY DONE Emil!!!

--Ari]]>
      
   </content>
</entry>
<entry>
   <title>In London?  Wanna get &quot;In the Brain...&quot;?</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/in_london_wanna_get_in_the_bra_1.html" />
   <id>tag:blog.terracottatech.com,2008://1.105</id>
   
   <published>2008-04-25T15:14:31Z</published>
   <updated>2008-04-25T15:24:39Z</updated>
   
   <summary>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...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[Not sure that anyone should get inside my brain, but we are going to try anyhow. <a href="http://skillsmatter.com/event/apache-tomcat/terracotta-open-source-network-attached-memory"> June 24th, in London at Skills Matter</a>.  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 <a href="http://www.eecs.harvard.edu/~mdw/proj/seda/">SEDA</a>, 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.  <a href="http://dhruba.name/2008/04/25/in-the-brain-of-ari-zilka-terracotta-open-source-network-attached-memory/">Its energizing to see people get excited</a> after using the demos, samples, and especially after having written their first TC-config file for their own app.

See you there!!!

--Ari




]]>
      
   </content>
</entry>
<entry>
   <title>The Book Is Almost Done</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/the_book_is_almost_done.html" />
   <id>tag:blog.terracottatech.com,2008://1.104</id>
   
   <published>2008-04-24T07:11:32Z</published>
   <updated>2008-04-24T07:17:56Z</updated>
   
   <summary>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...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[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.  <a href="http://www.amazon.com/Definitive-Guide-Terracotta-Hibernate-Scalability/dp/1590599861/ref=pd_bbs_sr_2?ie=UTF8&s=books&qid=1209017566&sr=1-2">Get your copy now</a>.



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

]]>
      
   </content>
</entry>
<entry>
   <title>Lock profiling across JVMs in a cluster</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/lock_profiling_across_jvms_in_1.html" />
   <id>tag:blog.terracottatech.com,2008://1.103</id>
   
   <published>2008-04-17T21:48:33Z</published>
   <updated>2008-04-18T00:30:28Z</updated>
   
   <summary>I&apos;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...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      <![CDATA[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 <strong>lots</strong> 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 <a href="http://en.wikipedia.org/wiki/Integration_by_parts">integration by parts</a>.  Even worse, I never remember the <a href="http://math2.org/math/integrals/more/tan.htm">integral of tan (x) dx</a>.  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:

<blockquote>
<pre>
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." );
        }
      }
  }
}
</pre>
</blockquote>


The Terracotta config to cluster this looks like the following:
<blockquote> 
<pre>
&lt;instrumented-classes&gt;
        &lt;include&gt;
          &lt;class-expression&gt;*..*&lt;/class-expression&gt;
        &lt;/include&gt;
      &lt;/instrumented-classes&gt;

      &lt;roots&gt;
        &lt;root&gt;
          &lt;field-name&gt;Main.a&lt;/field-name&gt;
        &lt;/root&gt;
        &lt;root&gt;
          &lt;field-name&gt;Main.b&lt;/field-name&gt;
        &lt;/root&gt;
        &lt;root&gt;
          &lt;field-name&gt;Main.barrier&lt;/field-name&gt;
        &lt;/root&gt;
      &lt;/roots&gt;

     &lt;locks&gt;
        &lt;autolock&gt;
          &lt;method-expression&gt;* *..*.*(..)&gt;/method-expression&lt;
        &lt;/autolock&gt;
      &lt;/locks&gt;
</pre>
</blockquote>

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

<blockquote>
Waiting for my partner...
</blockquote>

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

<blockquote>
ref1 =[1000]. Sleeping.
</blockquote>

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:

<a href="http://blog.terracottatech.com/LockProfiler.png"><img alt="LockProfiler.png" src="http://blog.terracottatech.com/LockProfiler-thumb.png" width="1155" height="311" /></a>
(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).

<a href="http://blog.terracottatech.com/SortingLocks.png"><img alt="SortingLocks.png" src="http://blog.terracottatech.com/SortingLocks-thumb.png" width="828" height="273" /></a>
(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.

<a href="http://blog.terracottatech.com/BlockingEachOther.png"><img alt="BlockingEachOther.png" src="http://blog.terracottatech.com/BlockingEachOther-thumb.png" width="833" height="234" /></a>
(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.

<a href="http://blog.terracottatech.com/CodeLocations.png"><img alt="CodeLocations.png" src="http://blog.terracottatech.com/CodeLocations-thumb.png" width="801" height="188" /></a>
(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




]]>
      
   </content>
</entry>
<entry>
   <title>How to profile locks with Terracotta (stay tuned)</title>
   <link rel="alternate" type="text/html" href="http://blog.terracottatech.com/2008/04/how_to_profile_locks_with_terr.html" />
   <id>tag:blog.terracottatech.com,2008://1.102</id>
   
   <published>2008-04-16T06:05:56Z</published>
   <updated>2008-04-16T06:08:59Z</updated>
   
   <summary>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...</summary>
   <author>
      <name></name>
      
   </author>
   
   
   <content type="html" xml:lang="en" xml:base="http://blog.terracottatech.com/">
      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&apos;t realize is there.

Stay tuned...

--Ari
      
   </content>
</entry>

</feed>
