5 ms·
[Context: I used to work at Terracotta. I currently do Clojure. I haven't had much time yet to look at Avout other than reading the same web pages you have.]
by puredanger 15y ago
[Context: I used to work at Terracotta. I currently do Clojure. I haven't had much time yet to look at Avout other than reading the same web pages you have.]
Terracotta has several kinds of distributed computing infrastructure - cluster infrastructure, distributed lock management, and shared memory (this is not all, but covers most of the distributed aspects). Maybe also important are data structures that are tuned to leverage this infrastructure (Ehcache is the most used one but also other java.util.concurrent classes). Terracotta is primarily focused on Java which is inherently based around mutable state and locks to protect it. Terracotta makes that state shared across the cluster and the locks protecting it distributed. Distributed locks in Java code are either done by leveraging the transaction semantics implied by synchronized keyword or Reentrant[ReadWrite]Locks - that is, it starts from standard Java memory model semantics and extends things from there. Most of the extensions are about weakening the model in ways that support common code patterns while allowing for greater distributed concurrency. The Ehcache distributed product hides some of the common complexities with mutable Java objects by focusing on Serializable keys/values (which users don't expect to retain object identity).
Avout is leveraging Zookeeper to provide the infrastructure, then layering the distributed locks and other Clojure state/identity mechanisms over the top. Avout can take advantage of two key aspects: 1) immutable data (which simplifies many hard problems in dealing with shared data and 2) focusing on Clojure change mechanisms which do not (externally) rely on locks, giving a lot more freedom in implementation. The latter defines transactional boundaries in much the same way that Java synchronization is leveraged by Terracotta to define transactional boundaries.
So I think saying that this is "Terracotta for Clojure" is a little true in that there is a bunch of overlap in the kinds of problems they're solving, but also much different in approach. For example, Clojure uses an MVCC + retry model of state change which Terracotta does not. I'm not trying to say either is better or worse - they are just different. Terracotta is also an inherently client/server model with a server cluster either collaboratively (via multiple actives) or redundantly (via hot backups) managing the shared state and a client cluster implementing the application. Avout seems to be more of a peered solution where some of the peers can write to stores (like Mongo).
Interestingly, it is fairly trivial to write a distributed lock manager over Terracotta - they have built demos like that (http://dsoguy.blogspot.com/2010/05/couple-minutes-with-terracotta-toolkit.html http://dsoguy.blogspot.com/2010/05/couple-minutes-with-terra...) but never released such a thing afaik. That implies to me that you could swap the Zookeeper+locks infrastructure with Terracotta without too much trouble. Given the many man-years of effort that have gone into optimizing the Terracotta distributed lock manager, that may be a big win for some use cases.