Scalable systems make us face challenges like concurrency, distribution, fault tolerance, elasticity, etc. Akka not only steps up to meet these, but it makes writing scalable software particularly easy. We will demo Akka's most important tool, the actor model, using a vivid example and live coding.
18. Akka’s vision
• Simpler concurrency (scale up)
• Simpler distribution (scale out)
• Simpler fault-tolerance (self healing)
• All of that with a single unified programming model
21. The Akka toolkit
• Akka runs on the JVM
• Akka can be used from Java and Scala
22. The Akka toolkit
• Akka runs on the JVM
• Akka can be used from Java and Scala
• Akka can be integrated with common infrastructure,
e.g. Spring, Camel, ZeroMQ, etc.
29. What is an actor?
• Carl Hewitt (1973): Fundamental unit of computation
30. What is an actor?
• Carl Hewitt (1973): Fundamental unit of computation
• Behavior - react on messages it receives
31. What is an actor?
• Carl Hewitt (1973): Fundamental unit of computation
• Behavior - react on messages it receives
• State - shielded from the rest of the world, no need for synchronization
32. What is an actor?
• Carl Hewitt (1973): Fundamental unit of computation
• Behavior - react on messages it receives
• State - shielded from the rest of the world, no need for synchronization
• Communication - interact with other actors exclusively via messages
33. What is an actor?
• Carl Hewitt (1973): Fundamental unit of computation
• Behavior - react on messages it receives
• State - shielded from the rest of the world, no need for synchronization
• Communication - interact with other actors exclusively via messages
• “One actor is no actor” - they come in systems
43. Receive messages
public class Hello extends UntypedActor {
@Override
public void onReceive(Object message) {
System.out.println("Hello, world!");
}
}
44. Receive messages
public class Hello extends UntypedActor {
public int count = 0;
@Override
public void onReceive(Object message) {
count += 1;
System.out.println(
"Hello for the " + count + " time!"
);
}
}
45. Receive messages
public class Hello extends UntypedActor {
public int count = 0;
One at a time
@Override
public void onReceive(Object message) {
count += 1;
System.out.println(
"Hello for the " + count + " time!"
);
}
}
60. Embrace failure
• Let it crash!
• Supervision: Like in real life, parents supervise their children
61. Embrace failure
• Let it crash!
• Supervision: Like in real life, parents supervise their children
• Depending on the parent’s supervisor strategy,
failing actors can get stopped, restarted or resumed
79. Benefits of using Akka actors
• You don’t have to deal with concurrency details
80. Benefits of using Akka actors
• You don’t have to deal with concurrency details
• You can manage failures easily
81. Benefits of using Akka actors
• You don’t have to deal with concurrency details
• You can manage failures easily
• Distribution is just a deployment decision
(not covered here)