SlideShare a Scribd company logo
1 of 83
Akka in action
  JAX London 2012
   Heiko Seeberger
What is scalability?
What is scalability?


• Ability of a system to handle growing work or
What is scalability?


• Ability of a system to handle growing work or
• its ability to be enlarged to accommodate growth.
Why should we
care about scalability?
Because of the human nature
So how can we build
  scalable systems?
Scaling up
Concurrency



 Scaling up
Scaling out
Distribution



Scaling out
So how can we easily build
    scalable systems?
Akka in Action: Heiko Seeburger
Akka’s vision
Akka’s vision

• Simpler concurrency (scale up)
Akka’s vision

• Simpler concurrency (scale up)
• Simpler distribution (scale out)
Akka’s vision

• Simpler concurrency (scale up)
• Simpler distribution (scale out)
• Simpler fault-tolerance (self healing)
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
The Akka toolkit
The Akka toolkit


• Akka runs on the JVM
The Akka toolkit


• Akka runs on the JVM
• Akka can be used from Java and Scala
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.
What’s inside the toolbox?
What’s inside the toolbox?

• Actors
What’s inside the toolbox?

• Actors
• Agents
What’s inside the toolbox?

• Actors
• Agents
• Dataflow concurrency
What’s inside the toolbox?

• Actors
• Agents
• Dataflow concurrency
• STM
What is an actor?
What is an actor?

• Carl Hewitt (1973): Fundamental unit of computation
What is an actor?

• Carl Hewitt (1973): Fundamental unit of computation
  •   Behavior - react on messages it receives
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
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
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
Other notions of an actor
Other notions of an actor


• Implementation of message passing concurrency
Other notions of an actor


• Implementation of message passing concurrency
• Isolated lightweight processes
Other notions of an actor


• Implementation of message passing concurrency
• Isolated lightweight processes
• Asynchronous and non-blocking
The Akka Actor
The Akka Actor
The Akka Actor
The Akka Actor
Receive messages
Receive messages

public class Hello extends UntypedActor {

    @Override
    public void onReceive(Object message) {
      System.out.println("Hello, world!");
    }
}
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!"
      );
    }
}
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!"
      );
    }
}
Send messages
Send messages


  ActorRef hello = ...
  hello.tell("Hi!");
Send messages


Asynchronous and
   ActorRef hello = ...
   hello.tell("Hi!");
   nonblocking
The Akka ActorSystem
The Akka ActorSystem
The Akka ActorSystem
Create an actor system
Create an actor system


   ActorSystem system =
     ActorSystem.create("hello");
Create a top-level actor
Create a top-level actor


 ActorRef hello =
   system.actorOf(new Props(new Hello()));
Create a child actor
Create a child actor


ActorRef child =
  context().actorOf(new Props(new Child()));
Embrace failure
Embrace failure


• Let it crash!
Embrace failure


• Let it crash!
• Supervision: Like in real life, parents supervise their children
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
HakkyHour demo
The HakkyHour bar
The HakkyHour bar

• Our drinks: Akkarita, MaiPlay, PinaScalada
The HakkyHour bar

• Our drinks: Akkarita, MaiPlay, PinaScalada
• Our actors: guests, waiters, head waiter, barkeepers
The HakkyHour bar

• Our drinks: Akkarita, MaiPlay, PinaScalada
• Our actors: guests, waiters, head waiter, barkeepers
• Our messages: Order, drink served, complaint, etc.
The HakkyHour bar

• Our drinks: Akkarita, MaiPlay, PinaScalada
• Our actors: guests, waiters, head waiter, barkeepers
• Our messages: Order, drink served, complaint, etc.
• Our failures: Guest drunk, waiter frustrated
HakkyHour actor system
HakkyHour messages
HakkyHour messages
HakkyHour messages
HakkyHour messages
HakkyHour messages
HakkyHour messages
HakkyHour messages
Live demo ...
Why does Akka make building
  scalable systems easy?
Benefits of using Akka actors
Benefits of using Akka actors


• You don’t have to deal with concurrency details
Benefits of using Akka actors


• You don’t have to deal with concurrency details
• You can manage failures easily
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)
Questions?
Thank you!
Twitter: @hseeberger

More Related Content

Similar to Akka in Action: Heiko Seeburger

Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Typesafe
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsJonas Bonér
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleansBill Tulloch
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarGal Marder
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuSalesforce Developers
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remanijaxconf
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling SoftwareAbdelmonaim Remani
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupRoy Russo
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
Using Hystrix to Build Resilient Distributed Systems
Using Hystrix to Build Resilient Distributed SystemsUsing Hystrix to Build Resilient Distributed Systems
Using Hystrix to Build Resilient Distributed SystemsMatt Jacobs
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den HoekRubiX BV
 

Similar to Akka in Action: Heiko Seeburger (20)

Akka Fundamentals
Akka FundamentalsAkka Fundamentals
Akka Fundamentals
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Akka.Net Overview
Akka.Net OverviewAkka.Net Overview
Akka.Net Overview
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and Quasar
 
akka-scalaphx-jun2015
akka-scalaphx-jun2015akka-scalaphx-jun2015
akka-scalaphx-jun2015
 
Akka Actors
Akka ActorsAkka Actors
Akka Actors
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and Heroku
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remani
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling Software
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
 
3 years with Clojure
3 years with Clojure3 years with Clojure
3 years with Clojure
 
Actors evolved- Rotem Hermon
Actors evolved- Rotem HermonActors evolved- Rotem Hermon
Actors evolved- Rotem Hermon
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
Using Hystrix to Build Resilient Distributed Systems
Using Hystrix to Build Resilient Distributed SystemsUsing Hystrix to Build Resilient Distributed Systems
Using Hystrix to Build Resilient Distributed Systems
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den Hoek
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 

More from JAX London

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityJAX London
 
Devops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisDevops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisJAX London
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsJAX London
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisJAX London
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerJAX London
 
Worse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyWorse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyJAX London
 
Java performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJava performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJAX London
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfHTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfJAX London
 
Play framework 2 : Peter Hilton
Play framework 2 : Peter HiltonPlay framework 2 : Peter Hilton
Play framework 2 : Peter HiltonJAX London
 
Complexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundComplexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundJAX London
 
Why FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberWhy FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberJAX London
 
NoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundNoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundJAX London
 
Closures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderClosures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderJAX London
 
Java and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJava and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJAX London
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsJAX London
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonJAX London
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaJAX London
 
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerThe Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerJAX London
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...JAX London
 

More from JAX London (20)

Everything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexityEverything I know about software in spaghetti bolognese: managing complexity
Everything I know about software in spaghetti bolognese: managing complexity
 
Devops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick DeboisDevops with the S for Sharing - Patrick Debois
Devops with the S for Sharing - Patrick Debois
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
 
It's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick DeboisIt's code but not as we know: Infrastructure as Code - Patrick Debois
It's code but not as we know: Infrastructure as Code - Patrick Debois
 
Locks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael BarkerLocks? We Don't Need No Stinkin' Locks - Michael Barker
Locks? We Don't Need No Stinkin' Locks - Michael Barker
 
Worse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin HenneyWorse is better, for better or for worse - Kevlin Henney
Worse is better, for better or for worse - Kevlin Henney
 
Java performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha GeeJava performance: What's the big deal? - Trisha Gee
Java performance: What's the big deal? - Trisha Gee
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias WessendorfHTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
 
Play framework 2 : Peter Hilton
Play framework 2 : Peter HiltonPlay framework 2 : Peter Hilton
Play framework 2 : Peter Hilton
 
Complexity theory and software development : Tim Berglund
Complexity theory and software development : Tim BerglundComplexity theory and software development : Tim Berglund
Complexity theory and software development : Tim Berglund
 
Why FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave GruberWhy FLOSS is a Java developer's best friend: Dave Gruber
Why FLOSS is a Java developer's best friend: Dave Gruber
 
NoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim BerglundNoSQL Smackdown 2012 : Tim Berglund
NoSQL Smackdown 2012 : Tim Berglund
 
Closures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel WinderClosures, the next "Big Thing" in Java: Russel Winder
Closures, the next "Big Thing" in Java: Russel Winder
 
Java and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk PepperdineJava and the machine - Martijn Verburg and Kirk Pepperdine
Java and the machine - Martijn Verburg and Kirk Pepperdine
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian Robinson
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun Gupta
 
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian PloskerThe Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
The Big Data Con: Why Big Data is a Problem, not a Solution - Ian Plosker
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 

Akka in Action: Heiko Seeburger