Akka Reaches 1.0 Status: Brings the Actor Model to Java and Scala
Akka is a library, written in Scala, that uses the Actor model to simplify writing fault-tolerant, highly scalable applications in both Java and Scala. The Actor model, which was initially presented by Carl Hewitt in 1973, has been successfully employed in languages like Erlang and in the telecoms industry where highly scalable systems with very high availability are common.
Scala language designer Martin Odersky has said
Akka actors have a lot of things going for them : they are very scalable, they have high performance, they work very well in distributed systems
Project lead Jonas Bonér has announced today that Akka has reached its 1.0 milestone. InfoQ spoke to Bonér to find out more about the project.
InfoQ: The Actor model has some striking parallels to the basic "fire-and-forget" pattern in messaging (JMS-type) systems. What advantages does it have over a messaging based system?
The Actor model is asynchronous and non-blocking like most messaging systems but it has some important differences.
First it is a unified single abstraction over both concurrency and distributed computing. Actors are location transparent, it doesn't matter if the actor reference you hold on to represents an actor in-process or on another physical machine. This is very powerful both for the developer and for the runtime which can utilize this by rebalancing the cluster, moving actors around to optimize locality of reference, etc.
Second, an actor allows you to redefine its behavior at runtime; also known as HotSwap. This is very powerful, both when implementing state machines or state dependent behavior in which the actor itself can update its behavior based on context, as well as being able to update actors from the outside (even remotely); fixing bugs or upgrading code without having to shut down the system.
InfoQ: What happens to a message in the event of an actor dying due to an error? How do you handle "poison message" type scenarios?
We have two scenarios:
- If the message resides in an actor's mailbox and has not yet been taken from the mailbox to be processed by the actor, then the message will continue to reside in the mailbox. The actor and its mailbox are decoupled so that the runtime can restart the crashed actor by throwing the dead actor away and starting up a new instance, while its mailbox is left untouched. The Cloudy Akka commercial add-on modules also add a set of durable mailboxes that will survive node crash, for example a file-based journaling transaction log, that can be used for increased reliability.
- If the message has been taken from the mailbox and is being processed by the actor, then if the actor crashes the message is gone and will not be redelivered. This is by design and is the way most actor-based systems, for example Erlang, work. However, Akka 1.1 will add guaranteed delivery of messages for both local and remote actors.
InfoQ: The Actor model is commonly encountered in telecoms scenarios. Can you give us some examples of other industries and projects where Akka has been used?
Akka is deployed in production at numerous companies in many different industries such as Finance & Banking, Betting & Gaming, Telecom, Simulation, Television & Media, eCommerce and Social Media sites. A common theme across all these industries is that they employ systems that are highly transactional, need high throughput, low latency and carrier-grade availability (5 nines or more). Examples are Transaction Processing Systems, Reliable Services Systems, Enterprise Integration, Event-driven Architecture, CQRS & Event Sourcing, Complex Event Stream Processing, Grid Computing, Analysis of large datasets and Batch Processing.
InfoQ: Akka offers both a Java and Scala API. At present do your users tend to be developing with Scala or Java?
Akka is written in Scala and born out of the Scala community, therefore it has naturally had the most adoption among Scala users, but with the release of Akka 1.0 we have made sure that the Java API is as good and feature-complete as the Scala API, and we are seeing more and more Java developers using Akka. Akka's Spring module and Typed Actors makes it very easy to use from Java.
InfoQ: How does Akka integrate with other libraries and frameworks?
Akka has a small core but a wide range of add-on modules, as part of the Akka Modules project, which provide integration with other libraries and frameworks. Some examples include modules for Spring, Google Guice, Apache Camel, AMQP and many NOSQL databases. Especially the Akka Camel module is worth looking into since it can turn Akka into an ESB with over 80 different endpoint drivers for communicating with all kinds of other systems and resources in an idiomatic Actor-style way.
InfoQ: What new features have been introduced since the 0.7 release we covered last year?
0.7 was almost a year ago and since then it has improved immensely, it is almost a completely different product. Since then we have added several hundred features and improvements. Here are some of the highlights:
- Serializable, immutable, network-aware ActorRefs that are decoupled from the actor instance
- Serialization of actors:
- Deep serialization (including mailbox) so actors can be moved around in cluster
- ActorRef serialization so that references can be sent around that remember and use its original actor instance
- JTA-aware STM transactions
- Vast improvements to the remoting:
- RemoteClient and RemoteServer event subscription API
- New more efficient and rich network protocol
- New API that will allow developers to plug in different transports in the future (0MQ, AMQP or others)
- Per-session remote actors
- Secure cookie handshake for remote actors
- Untrusted mode to use with untrusted clients
- Rewritten supervisor management, making use of ActorRef, now really kills the actor instance and replaces it with the original node
- Much improved Java API. Now (almost) as rich as the Scala API
- New actors: UntypedActor and TypedActor have made it possible to interface from other languages such as JRuby and Groovy
- Improved performance and scalability, lower latency and memory footprint
Bonér also cited improvemtns to the Camel and AMQP modules, and a decrease in per-actor memory footprint which, he suggested, would allow 25% more actors to run on the same hardware. Akka also gains JTA and OSGi support, support for NoSQL databases, and a huge number of other tweaks and changes. A complete list can be found in the release notes.
InfoQ:What are your plans beyond the 1.0 release?
We plan to release Akka 1.1 shortly after the 1.0 release which will have:
- Zero dependency akka-actor module/JAR
- Improved HTTP module with WebSocket support and more
- Guaranteed delivery for sending messages to local and remote actors (idempotent using repeater)
- Much improved performance and scalability of Akka's default dispatcher
- Much improved STM; complete redesign with better performance & scalability and richer API
- Richer future API
- Support for the Scalaz library
- and more
Beyond 1.1 we have distributed STM and the release of the commercial Cloudy Akka add-on suite for clustering, management/monitoring and provisioning.
Jon Brisbin,Stephane Maldini Nov 26, 2014