Jonas Bonér released an integration module for Terracotta that allows Scala actors to scale across servers.
Scala implements the Actor model for concurrency: because an Actor contains no shared state, Actor-based concurrency is simpler to work with than the shared-state concurrency model of, for example, Java. Due to lack of shared state, Actor-based concurrency can also scale to potentially larger number of processors than parallel applications relying on shared-state.
While many concurrent systems today aim to take advantage of multi-core CPUs, Actor-based concurrency was initially developed for multi-processor machines and distributed clusters. Jonas Boner recently made it possible to distribute Actor-based Scala programs on a cluster of compute nodes using Terracotta's open-source JVM clustering tool.
An Actor is an abstraction that implements Message-Passing Concurrency. Actors have no shared state and are communicating by sending and receiving messages. This is a paradigm that provides a very different and much simple concurrency model than Shared-State Concurrency (the scheme adopted by C, Java, C# etc.) and is avoiding most of the latter one’s complexity and problems.
This makes it possible to write code that is deterministic and side-effect-free, something that makes it easier to write, test, understand and reason about. Each Actor has a mailbox in which it receives incoming messages and normally uses pattern matching on the messages to decide if a message is interesting if action is needed.
Boner points out that while Actor-based shared-nothing concurrency is potentially useful, it also requires a new programming paradigm:
How can we make applications build on this “new” programming model highly available and how can we scale them out, if necessary. Would it not be cool if we could not only parallelize our application onto multiple threads but also onto multiple machines?
I have spent some time last weeks looking into if would make sense to utilize Terracotta to cluster the Scala Actors library to give a platform on which we can both scale Actors out in a distributed fashion and ensure full fault tolerance and high-availability. The result of this exercise have been successful and I’m happy to announce that they work very nice together.
Boner released the source code for a Terracotta integration module that make Actor-based Scala programming simple with Terracotta. Once configured, the Terracotta infrastructure transparently distributes Actor instances on available JVMs.
What do you think of Scala's Actor-based concurrency, and of scaling Actor-based programs with Terracotta?