Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Akka 1.1 Released, Brings Many Improvements to Futures and Performance, Reduces Dependencies,

Akka 1.1 Released, Brings Many Improvements to Futures and Performance, Reduces Dependencies,

This item in japanese

Akka 1.1 was released today with a few improvements over Akka 1.0. Today also saw the release of Scala 2.9 (Akka 1.1 requires Scala 2.9); both Scala and Akka are now managed by Martin Odersky's and Jonas  Bonér's new company Typesafe , which provides training and support for Akka and Scala, as well as commercial products built on these technologies. An integrated stack is available from Typesafe. 

Akka 1.1 (akka-actor) now has no dependencies besides Scala 2.9.  Besides other changes, a lot of work has gone into Futures (from the announcement):

- Dataflow API for Futures using delimited continuations so you can write seemingly blocking code that will not block runtime
- Futures are now fully Monadic which means that they are ready for for-comprehension goodness
- Futures now have lots of non-blocking methods allowing composition of Futures without blocking
- Futures can now be executed natively on all the Dispatchers

Functional programmers will be happy to hear that Futures are Monads now, complete with map and flatMap methods which allow to use Scala's for comprehensions (from the docs ):

val f = for {
  a <- Future(10 / 2) // 10 / 2 = 5
  b <- Future(a + 1)  //  5 + 1 = 6
  c <- Future(a - 1)  //  5 - 1 = 4
} yield b * c         //  6 * 4 = 24

val result = f.get()

Scala's for comprehensions can be used like Haskell's do notation for monadic code, ie. its a compact way to string together computations sequentially. (For a quick introduction to Monads see "Monads Made Easy").

InfoQ caught up with Jonas  Bonér at GotoCon Copenhagen 2011 and talked about Akka 1.1 and the future of Akka.

InfoQ: Akka 1.1 now requires Scala 2.9 - what's the reason for that? Are you using any new features in Scala 2.9 (if yes, which ones)? Have you encountered any problems moving from Scala 2.8 to 2.9?

Scala 2.9.0 is a lot better than 2.8.x, we are utilizing both bug fixes, performance enhancements as well as some new features. We have not had any major issues upgrading from 2.8, it's been smooth.

InfoQ: What are the await/future methods in Agent? Do they cause the current actor to be suspended and rescheduled when await returns?

Agent.future is sending a message to the underlying actor querying it for the current value of the Agent. It does that using the !!! method, which returns immediately with a Future.
Agent.await is an alias for Agent.future.await.result.get, so it is a blocking call, while Agent.future gives you options to use the new API for non-blocking Future composition.

InfoQ: How was the Akka 1.1 default dispatcher improved over 1.0; where is HawtDispatch useful or faster?

It is hard to summarize it in a few lines. It has gone through a series of small refinements over time. HawtDispatch is never faster. The HawtDispacher in Akka is moved out of Akka core and is deprecated. The only place I see it useful is if you want to do low-level NIO. Here is the result from the latest benchmark:

For more details on these benchmarks see the discussion on the akka-user list.

: Any big features/changes already planned for Akka 2.0?

Yeah. We are working hard now moving the cluster support in commercial Akka product suite into Akka Open Source. We will ship this with Akka 2.0 in the beginning of the fall. Clustering (or remoting or distribution if you want to call it that) will be completely abstracted away into a configuration task. This means that you can take any Akka application that runs only using local actors and configure it (from the outside) to be clustered, replicated, routed etc.

Here is a list of what it will include.

In Akka 2.0:
  • Transparent and adaptive load-balancing/routing
  • Transparent adaptive cluster rebalancing
  • Automatic replication with automatic fail-over upon node crash
  • Durable actor mailboxes
  • Subscription-based cluster membership service (add/remove nodes on the fly)
  • Event Sourcing based on a highly available scalable transaction log
  • Highly available centralized configuration service * Leader election
Post Akka 2.0:
  • Compute Grid/MapReduce
  • Data Grid
  • Distributed STM
Cloudy Akka (e.g. the commercial add-on product suite) will consist solely of operations stuff such as monitoring, management, provisioning, dashboard, EC2 support etc.


Rate this Article