What is Akka-Mobile? Right now it’s an idea. It’s my semester term project at the University of Applied Science in Rapperswil. In this blog post I give a short overview of the idea.
What is Akka?
Akka is a framework for Scala (and also Java) to bring Erlang style actors (and tons of other things) to the JVM. In the actor model we have actors which communicate through message passing with each other. Each actor can react to messages, do some computation and sent messages to other actors which he knows. The message passing it the only way actors can communicate, there not shared state or other communication channels.
I just cite from the Akka website:
“We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it’s because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the Actor Model together with Software Transactional Memory we raise the abstraction level and provide a better platform to build correct concurrent and scalable applications.”
“For fault-tolerance we adopt the “Let it crash” / “Embrace failure” model which have been used with great success in the telecom industry to build applications that self-heal, systems that never stop.”
The Actor Model works well for distributed, ‘event’-oriented and fault tolerant environments. Where do we have such systems? Yes, in the mobile space! Think about all the phones our there running tons of applications. Many of these applications communicate with a central service or even between devices. Think about all the applications on your phone which have ‘real-time’ communication features? Chat apps, social apps like Facebook & Twitter, GPS apps which incorporates the latest traffic information etc. And all these applications have to deal with network faults, message delivery and coordination.
So I think the Actor model is a good fit for these kinds of ‘real time’ applications on the phone. That’s why I want to get the Actor goodness on the phone.
30’000 Feet Overview
Ok, the basic idea is very simple. We simply bring the actors to the phone. These actors can communication locally or with a remote service. On the phone we can send messages to some actors running on the Server. On the server we can access each phone like an actor and send messages to it.
For example on the phone we simply can send a message to the server like this:
theServiceOnTheServer ! “Hi”
And on the server we can react to this and reply:
onMessage “Hi” => reply(“Hi there”)
These messages are then delivered to each mailbox of the actors running on the server and phone. There the actors then can read and reacht to these messages. The framework handles the communication, failures, etc. of the messages. Of course it won’t be a silver bullet and you still need to deal with errors. However with an Actor model dealing with errors is easier than with more traditional models (like exceptions).
Tons of Details
While the actor model provides are very simple model, there are tons of details which need to go into the implementation. How do deal with connection losses and offline devices? How are communication errors exposed to the actors? And of course additions for the mobile space should also be considered. For example messages which are only delivered when the device is actively used and other messages which are always delivered.
Back To Akka
Now of course I could go with a green field approach and implement everything from scratch, but that would be a lot of wasted effort. Akka already has solid implemented Actors including remote communications. However Akka is intended for servers and clusters. The current remote implementation isn’t really intended to be used on mobile devices. So my goal it the change that and bring parts of the Akka goodness to the mobile space.
Conclusion & Next Time
Ok, I want bring Akka actors to the mobile space. The motivation for this is that the actor model is a good fit for complex distributed computing, like in the mobile space.
Anyway, I will go into more details in future posts. Next time I will explain how to get Scala running on Android.
- Project CoPilot: Season 1, Episode 2
- 200 Posts, Yeah!