SlideShare une entreprise Scribd logo
1  sur  180
Télécharger pour lire hors ligne
Introducing

         Jonas Bonér
          CTO Typesafe
Introducing
Introducing

                Akka (Áhkká)
  The name comes from the goddess in the Sami
  (native swedes) mythology that represented all
        the wisdom and beauty in the world.

   It is also the name of a beautiful mountain in
         Laponia in the north part of Sweden
Introducing
Vision

Simpler
     Concurrency
     Scalability
     Fault-tolerance
Vision

...with a single unified
     Programming Model
     Managed Runtime
     Open Source Distribution
Manage System Overload
Scale UP & Scale OUT
Program at a Higher Level
Program at a Higher Level
Program at a Higher Level
• Never think in terms of shared state, state
   visibility, threads, locks, concurrent collections,
   thread notifications etc.
Program at a Higher Level
• Never think in terms of shared state, state
   visibility, threads, locks, concurrent collections,
   thread notifications etc.
• Low level concurrency plumbing BECOMES
   SIMPLE WORKFLOW - you only think about how
   messages flow in the system
Program at a Higher Level
• Never think in terms of shared state, state
   visibility, threads, locks, concurrent collections,
   thread notifications etc.
• Low level concurrency plumbing BECOMES
   SIMPLE WORKFLOW - you only think about how
   messages flow in the system
• You get high CPU utilization, low latency, high
   throughput and scalability - FOR FREE as part of
   the model
Program at a Higher Level
• Never think in terms of shared state, state
   visibility, threads, locks, concurrent collections,
   thread notifications etc.
• Low level concurrency plumbing BECOMES
   SIMPLE WORKFLOW - you only think about how
   messages flow in the system
• You get high CPU utilization, low latency, high
   throughput and scalability - FOR FREE as part of
   the model
• Proven and superior model for detecting and
   recovering from errors
Distributable by Design
Distributable by Design
Distributable by Design
• Actors are location transparent & distributable by design
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
• You get the PERFECT FABRIC for the CLOUD
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
• You get the PERFECT FABRIC for the CLOUD
 -   elastic & dynamic
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
• You get the PERFECT FABRIC for the CLOUD
 -   elastic & dynamic

 -   fault-tolerant & self-healing
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
• You get the PERFECT FABRIC for the CLOUD
 -   elastic & dynamic

 -   fault-tolerant & self-healing

 -   adaptive load-balancing, cluster rebalancing & actor migration
Distributable by Design
• Actors are location transparent & distributable by design
• Scale UP and OUT for free as part of the model
• You get the PERFECT FABRIC for the CLOUD
 -   elastic & dynamic

 -   fault-tolerant & self-healing

 -   adaptive load-balancing, cluster rebalancing & actor migration

 -   build extremely loosely coupled and dynamic systems that can
     change and adapt at runtime
Selection of Akka Production Users
How
can we achieve this?
How
can we achieve this?
Let’s use Actors




     How
can we achieve this?
What is an Actor?
What is an Actor?
What is an Actor?
• Akka's unit of code organization is called an Actor
What is an Actor?
• Akka's unit of code organization is called an Actor
• Actors helps you create concurrent, scalable and
   fault-tolerant applications
What is an Actor?
• Akka's unit of code organization is called an Actor
• Actors helps you create concurrent, scalable and
   fault-tolerant applications

• Like Java EE servlets and session beans, Actors is a
   model for organizing your code that keeps many
   “policy decisions” separate from the business logic
What is an Actor?
• Akka's unit of code organization is called an Actor
• Actors helps you create concurrent, scalable and
   fault-tolerant applications

• Like Java EE servlets and session beans, Actors is a
   model for organizing your code that keeps many
   “policy decisions” separate from the business logic

• Actors may be new to many in the Java community,
   but they are a tried-and-true concept (Hewitt 1973)
   used for many years in telecom systems with 9 nines
   uptime
Actors can be seen as
Virtual Machines (nodes)
  in Cloud Computing
Encapsulated
and decoupled
 black boxes...
Encapsulated
and decoupled
 black boxes...
...that manages their own
   memory and behavior
...that manages their own
   memory and behavior
Communicates
with asynchronous
   non-blocking
     messages
Communicates
with asynchronous
   non-blocking
     messages
Elastic - grow and
shrink on demand
Elastic - grow and
shrink on demand
Elastic - grow and
shrink on demand
Elastic - grow and
shrink on demand
Hot deploy - change
behavior at runtime
Hot deploy - change
behavior at runtime
Now - if we replace

             with
                    Actor
EVERYTHING will STILL HOLD for both
  LOCAL and DISTRIBUTED Actors
What can I use Actors for?
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener

  -   a singleton or service
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener

  -   a singleton or service

  -   a router, load-balancer or pool
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener

  -   a singleton or service

  -   a router, load-balancer or pool

  -   a Java EE Session Bean or Message-Driven Bean
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener

  -   a singleton or service

  -   a router, load-balancer or pool

  -   a Java EE Session Bean or Message-Driven Bean

  -   an out-of-process service
What can I use Actors for?
 In different scenarios, an Actor may be an
 alternative to:
  -   a thread

  -   an object instance or component

  -   a callback or listener

  -   a singleton or service

  -   a router, load-balancer or pool

  -   a Java EE Session Bean or Message-Driven Bean

  -   an out-of-process service

  -   a Finite State Machine (FSM)
So, what is the
Actor Model?
Carl Hewitt’s definition




    http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:




                http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing




                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage




                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage

    -   Communication




                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage

    -   Communication

-   3 axioms - When an Actor receives a message it can:




                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage

    -   Communication

-   3 axioms - When an Actor receives a message it can:
    -   Create new Actors




                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage

    -   Communication

-   3 axioms - When an Actor receives a message it can:
    -   Create new Actors

    -   Send messages to Actors it knows



                     http://bit.ly/hewitt-on-actors
Carl Hewitt’s definition
-   The fundamental unit of computation that embodies:
    -   Processing

    -   Storage

    -   Communication

-   3 axioms - When an Actor receives a message it can:
    -   Create new Actors

    -   Send messages to Actors it knows

    -   Designate how it should handle the next message it receives

                     http://bit.ly/hewitt-on-actors
4 core Actor operations
       0. DEFINE
       1. CREATE
       2. SEND
       3. BECOME
       4. SUPERVISE
0. DEFINE
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}
0. DEFINE
                        Define the message(s) the Actor
                         should be able to respond to


public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}
0. DEFINE
                        Define the message(s) the Actor
                         should be able to respond to


public class Greeting implements Serializable {
   public final String who;
                        Define the Actor class
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}
0. DEFINE
                        Define the message(s) the Actor
                         should be able to respond to


public class Greeting implements Serializable {
   public final String who;
                        Define the Actor class
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
                            Define the Actor’s behavior
}
Scala version
case class Greeting(who: String)

class GreetingActor extends Actor with ActorLogging {
  def receive = {
    case Greeting(who) => log.info("Hello {}", who)
  }
}
1. CREATE
• CREATE - creates a new instance of an Actor
• Extremely lightweight (2.7 Million per Gb RAM)
• Very strong encapsulation - encapsulates:
  -    state

  -    behavior

  -    message queue

• State & behavior is indistinguishable from each other
• Only way to observe state is by sending an actor a
  message and see how it reacts
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }             Create an Actor system
    }
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }             Create an Actor system
    }                                             Actor configuration
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }             Create an Actor system
    }                                             Actor configuration
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");



                                                          Give it a name
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }             Create an Actor system
    }                                              Actor configuration
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");


                                       Create the Actor
                                                           Give it a name
CREATE Actor
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }             Create an Actor system
    }                                              Actor configuration
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");


                                       Create the Actor
           You get an ActorRef back                        Give it a name
Actors can form hierarchies
          Guardian System Actor
Actors can form hierarchies
          Guardian System Actor




          system.actorOf(Props[Foo], “Foo”)
Actors can form hierarchies
             Guardian System Actor




       Foo   system.actorOf(Props[Foo], “Foo”)
Actors can form hierarchies
               Guardian System Actor




       Foo




             context.actorOf(Props[A], “A”)
Actors can form hierarchies
               Guardian System Actor




       Foo




      A      context.actorOf(Props[A], “A”)
Actors can form hierarchies
             Guardian System Actor




       Foo                           Bar




                                           A
      A          C




             E                                 C
B
                                     B

      D
Name resolution - like a file-system
                Guardian System Actor




          Foo                           Bar




                                              A
          A         C




                E                                 C
    B
                                        B

          D
Name resolution - like a file-system
                     Guardian System Actor



        /Foo

               Foo                           Bar




                                                   A
               A         C




                     E                                 C
    B
                                             B

               D
Name resolution - like a file-system
                         Guardian System Actor



            /Foo

                   Foo                           Bar



        /Foo/A
                                                       A
                   A         C




                         E                                 C
    B
                                                 B

                   D
Name resolution - like a file-system
                             Guardian System Actor



                /Foo

                       Foo                           Bar



            /Foo/A
                                                           A
                       A         C


 /Foo/A/B

                             E                                 C
       B
                                                     B

                       D
Name resolution - like a file-system
                                Guardian System Actor



                   /Foo

                          Foo                           Bar



              /Foo/A
                                                              A
                          A         C


 /Foo/A/B

                                E                                 C
       B
                                                        B

                          D
            /Foo/A/D
2. SEND
2. SEND
• SEND - sends a message to an Actor
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
• Everything happens Reactively
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
• Everything happens Reactively
 -   An Actor is passive until a message is sent to it,
     which triggers something within the Actor
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
• Everything happens Reactively
 -   An Actor is passive until a message is sent to it,
     which triggers something within the Actor

 -   Messages is the Kinetic Energy in an Actor system
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
• Everything happens Reactively
 -   An Actor is passive until a message is sent to it,
     which triggers something within the Actor

 -   Messages is the Kinetic Energy in an Actor system

 -   Actors can have lots of buffered Potential Energy
     but can't do anything with it until it is triggered by
     a message
2. SEND
• SEND - sends a message to an Actor
• Asynchronous and Non-blocking - Fire-forget
• Everything happens Reactively
 -   An Actor is passive until a message is sent to it,
     which triggers something within the Actor

 -   Messages is the Kinetic Energy in an Actor system

 -   Actors can have lots of buffered Potential Energy
     but can't do anything with it until it is triggered by
     a message

• EVERYTHING is asynchronous and lockless
Throughput on a single box




  +50 million messages per second
SEND message
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
greeter.tell(new Greeting("Charlie Parker"));
SEND message
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
greeter.tell(new Greeting("Charlie Parker"));


                    Send the message
Full example
public class Greeting implements Serializable {
   public final String who;
   public Greeting(String who) { this.who = who; }
}

public class GreetingActor extends UntypedActor {
    LoggingAdapter log = Logging.getLogger(getContext().system(), this);

        public void onReceive(Object message) throws Exception {
          if (message instanceof Greeting)
             log.info("Hello {}", ((Greeting) message).who);
          }
    }
}

ActorSystem system = ActorSystem.create("MySystem");
ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
greeter.tell(new Greeting("Charlie Parker"));
Scala version
case class Greeting(who: String)

class GreetingActor extends Actor with ActorLogging {
  def receive = {
    case Greeting(who) => log.info("Hello {}", who)
  }
}

val system = ActorSystem("MySystem")
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
greeter tell Greeting("Charlie Parker")
Reply
class SomeActor extends UntypedActor {
  void onReceive(Object msg) {
    if (msg instanceof User) {
      User user = (User) msg;
      // reply to sender
      getSender().tell(“Hi ” + user.name);
    }
  }
}
Scala version
class SomeActor extends Actor {
  def receive = {
    case User(name) =>
      // reply to sender
      sender tell (“Hi ” + name)
  }
}
Remote deployment
Just feed the ActorSystem with this configuration


   akka {
     actor {
       provider =    akka.remote.RemoteActorRefProvider
       deployment    {
         /Greeter    {
            remote   =
          }
       }
     }
   }
Remote deployment
Just feed the ActorSystem with this configuration

                                       Configure a Remote Provider
   akka {
     actor {
       provider =    akka.remote.RemoteActorRefProvider
       deployment    {
         /Greeter    {
            remote   =
          }
       }
     }
   }
Remote deployment
     Just feed the ActorSystem with this configuration

                                                  Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider =    akka.remote.RemoteActorRefProvider
                  deployment    {
                     /Greeter   {
                       remote   =
                     }
                  }
              }
           }
Remote deployment
     Just feed the ActorSystem with this configuration

                                                  Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider =    akka.remote.RemoteActorRefProvider
                  deployment    {
                     /Greeter   {
                       remote   =
                     }
                  }
    Define Remote Path
              }
           }
Remote deployment
    Just feed the ActorSystem with this configuration

                                             Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider = akka.remote.RemoteActorRefProvider
                  deployment {
                     /Greeter {
                       remote = akka://
                     }
                  }
    Define Remote Path
              }           Protocol
           }
Remote deployment
    Just feed the ActorSystem with this configuration

                                             Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider = akka.remote.RemoteActorRefProvider
                  deployment {
                     /Greeter {
                       remote = akka://MySystem
                     }
                  }
    Define Remote Path
              }           Protocol  Actor System
           }
Remote deployment
    Just feed the ActorSystem with this configuration

                                             Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider = akka.remote.RemoteActorRefProvider
                  deployment {
                     /Greeter {
                       remote = akka://MySystem@machine1
                     }
                  }
    Define Remote Path
              }           Protocol  Actor System Hostname
           }
Remote deployment
     Just feed the ActorSystem with this configuration

                                              Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider = akka.remote.RemoteActorRefProvider
                  deployment {
                     /Greeter {
                       remote = akka://MySystem@machine1:2552
                     }
                  }
    Define Remote Path
              }           Protocol  Actor System Hostname   Port
           }
Remote deployment
     Just feed the ActorSystem with this configuration

                                              Configure a Remote Provider
           akka {
For the Greeter actor {
              actor
                  provider = akka.remote.RemoteActorRefProvider
                  deployment {
                     /Greeter {
                       remote = akka://MySystem@machine1:2552
                     }
                  }
    Define Remote Path
              }           Protocol  Actor System Hostname   Port
           }



                       Zero code changes
3. BECOME
3. BECOME
• BECOME - dynamically redefines Actor’s behavior
3. BECOME
• BECOME - dynamically redefines Actor’s behavior
• Triggered reactively by receive of message
3. BECOME
• BECOME - dynamically redefines Actor’s behavior
• Triggered reactively by receive of message
• In a type system analogy it is as if the object changed
  type - changed interface, protocol & implementation
3. BECOME
• BECOME - dynamically redefines Actor’s behavior
• Triggered reactively by receive of message
• In a type system analogy it is as if the object changed
  type - changed interface, protocol & implementation
• Will now react differently to the messages it receives
3. BECOME
• BECOME - dynamically redefines Actor’s behavior
• Triggered reactively by receive of message
• In a type system analogy it is as if the object changed
  type - changed interface, protocol & implementation
• Will now react differently to the messages it receives
• Behaviors are stacked & can be pushed and popped
Why would I want to do that?
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
• Implement an FSM (Finite State Machine)
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
• Implement an FSM (Finite State Machine)
• Implement graceful degradation
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
• Implement an FSM (Finite State Machine)
• Implement graceful degradation
• Spawn up (empty) generic Worker processes that
  can become whatever the Master currently needs
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
• Implement an FSM (Finite State Machine)
• Implement graceful degradation
• Spawn up (empty) generic Worker processes that
  can become whatever the Master currently needs
• etc. use your imagination
Why would I want to do that?
• Let a highly contended Actor adaptively transform
  himself into an Actor Pool or a Router
• Implement an FSM (Finite State Machine)
• Implement graceful degradation
• Spawn up (empty) generic Worker processes that
  can become whatever the Master currently needs
• etc. use your imagination
• Very useful once you get the used to it
become
context.become(new Procedure[Object]() {
  void apply(Object msg) {
    // new body
    if (msg instanceof NewMessage) {
      NewMessage newMsg = (NewMessage)msg;
      ...
    }
  }
});
Actor context available
                          become
 from within an Actor



         context.become(new Procedure[Object]() {
           void apply(Object msg) {
             // new body
             if (msg instanceof NewMessage) {
               NewMessage newMsg = (NewMessage)msg;
               ...
             }
           }
         });
Scala version
  context become {
    // new body
    case NewMessage =>
      ...
  }
Load Balancing
Routers
val router =
 system.actorOf(
   Props[SomeActor].withRouter(
    RoundRobinRouter(nrOfInstances = 5)))




               Scala API
Router + Resizer
val resizer =
  DefaultResizer(lowerBound = 2, upperBound = 15)

val router =
  system.actorOf(
    Props[ExampleActor1].withRouter(
      RoundRobinRouter(resizer = Some(resizer))))




                   Scala API
Failure management in Java/C/C# etc.
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
   • To make things worse - errors do not propagate
     between threads so there is NO WAY OF EVEN
     FINDING OUT that something have failed
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
   • To make things worse - errors do not propagate
     between threads so there is NO WAY OF EVEN
     FINDING OUT that something have failed
   • This leads to DEFENSIVE programming with:
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
   • To make things worse - errors do not propagate
     between threads so there is NO WAY OF EVEN
     FINDING OUT that something have failed
   • This leads to DEFENSIVE programming with:
      • Error handling TANGLED with business logic
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
   • To make things worse - errors do not propagate
     between threads so there is NO WAY OF EVEN
     FINDING OUT that something have failed
   • This leads to DEFENSIVE programming with:
      • Error handling TANGLED with business logic
      • SCATTERED all over the code base
Failure management in Java/C/C# etc.
   • You are given a SINGLE thread of control
   • If this thread blows up you are screwed
   • So you need to do all explicit error handling
     WITHIN this single thread
   • To make things worse - errors do not propagate
     between threads so there is NO WAY OF EVEN
     FINDING OUT that something have failed
   • This leads to DEFENSIVE programming with:
      • Error handling TANGLED with business logic
      • SCATTERED all over the code base

      We can do better than this!!!
4. SUPERVISE
4. SUPERVISE
• SUPERVISE - manage another Actor’s failures
4. SUPERVISE
• SUPERVISE - manage another Actor’s failures
• Error handling in actors is handle by letting Actors
  monitor (supervise) each other for failure
4. SUPERVISE
• SUPERVISE - manage another Actor’s failures
• Error handling in actors is handle by letting Actors
  monitor (supervise) each other for failure
• This means that if an Actor crashes, a notification
  will be sent to his supervisor, who can react upon
  the failure
4. SUPERVISE
• SUPERVISE - manage another Actor’s failures
• Error handling in actors is handle by letting Actors
  monitor (supervise) each other for failure
• This means that if an Actor crashes, a notification
  will be sent to his supervisor, who can react upon
  the failure
• This provides clean separation of processing and
  error handling
...let’s take a
standard OO
  application
Which components have
critically important state
            and
 explicit error handling?
Fault-tolerant
 onion-layered
 Error Kernel
Error
Kernel
Error
Kernel
Error
Kernel
Error
Kernel
Error
Kernel
Error
Kernel
Node 1   Node 2
Error
Kernel
SUPERVISE Actor
   Every single actor has a
 default supervisor strategy.
 Which is usually sufficient.
  But it can be overridden.
SUPERVISE Actor
                  Every single actor has a
                default supervisor strategy.
                Which is usually sufficient.
                 But it can be overridden.
class Supervisor extends UntypedActor {
  private SupervisorStrategy strategy = new OneForOneStrategy(
    10,
    Duration.parse("1 minute"),
    new Function<Throwable, Directive>() {
      @Override public Directive apply(Throwable t) {
        if (t instanceof ArithmeticException)       return resume();
        else if (t instanceof NullPointerException) return restart();
        else                                        return escalate();
    }
  });

  @Override public SupervisorStrategy supervisorStrategy() {
SUPERVISE Actor
class Supervisor extends UntypedActor {
  private SupervisorStrategy strategy = new OneForOneStrategy(
    10,
    Duration.parse("1 minute"),
    new Function<Throwable, Directive>() {
      @Override public Directive apply(Throwable t) {
        if (t instanceof ArithmeticException)       return resume();
        else if (t instanceof NullPointerException) return restart();
        else                                        return escalate();
    }
  });

    @Override public SupervisorStrategy supervisorStrategy() {
      return strategy;
    }

    ActorRef worker = context.actorOf(new Props(Worker.class));

    public void onReceive(Object message) throws Exception {
      if (message instanceof Integer) worker.forward(message);
    }
}
Scala version
class Supervisor extends Actor {
  override val supervisorStrategy =
                     (maxNrOfRetries = 10, withinTimeRange = 1 minute) {
      case _: ArithmeticException => Resume
      case _: NullPointerException => Restart
      case _: Exception             => Escalate
  }

    val worker = context.actorOf(Props[Worker])

    def receive = {
      case n: Int => worker forward n
    }
}
Scala version
class Supervisor extends Actor {
  override val supervisorStrategy =
    OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
      case _: ArithmeticException => Resume
      case _: NullPointerException => Restart
      case _: Exception             => Escalate
  }

    val worker = context.actorOf(Props[Worker])

    def receive = {
      case n: Int => worker forward n
    }
}
Scala version
class Supervisor extends Actor {
  override val supervisorStrategy =
    AllForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
      case _: ArithmeticException => Resume
      case _: NullPointerException => Restart
      case _: Exception             => Escalate
  }

    val worker = context.actorOf(Props[Worker])

    def receive = {
      case n: Int => worker forward n
    }
}
Manage failure
class Worker extends Actor {
  ...

    override def preRestart(
      reason: Throwable, message: Option[Any]) {
      ... // clean up before restart
    }

    override def postRestart(reason: Throwable) {
      ... // init after restart
    }
}


                   Scala API
This was
Akka 2.x
This was
  Akka 2.x
Well...it’s a start...
...we have much much more
...we have much much more
TestKit           Cluster                      FSM
                                    IO
    HTTP/REST
                         EventBus
 Durable Mailboxes                          Pub/Sub
                            Camel
Microkernel
              TypedActor       SLF4J          AMQP
  ZeroMQ
                     Dataflow             Transactors
Agents
                Spring              Extensions
get it and learn more
       http://akka.io
    http://letitcrash.com
    http://typesafe.com
EOF

Contenu connexe

Tendances

Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin PodvalMartin Podval
 
Introduction to Microservices Patterns
Introduction to Microservices PatternsIntroduction to Microservices Patterns
Introduction to Microservices PatternsDimosthenis Botsaris
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams Reactive stream processing using Akka streams
Reactive stream processing using Akka streams Johan Andrén
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Flink Forward
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
Apache Kafka Fundamentals for Architects, Admins and Developers
Apache Kafka Fundamentals for Architects, Admins and DevelopersApache Kafka Fundamentals for Architects, Admins and Developers
Apache Kafka Fundamentals for Architects, Admins and Developersconfluent
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdfBernardDeffarges
 
CRDTs with Akka Distributed Data
CRDTs with Akka Distributed DataCRDTs with Akka Distributed Data
CRDTs with Akka Distributed DataMarkus Jura
 
Apache Flink and what it is used for
Apache Flink and what it is used forApache Flink and what it is used for
Apache Flink and what it is used forAljoscha Krettek
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistentconfluent
 
Designing Structured Streaming Pipelines—How to Architect Things Right
Designing Structured Streaming Pipelines—How to Architect Things RightDesigning Structured Streaming Pipelines—How to Architect Things Right
Designing Structured Streaming Pipelines—How to Architect Things RightDatabricks
 
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...(BDT403) Best Practices for Building Real-time Streaming Applications with Am...
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...Amazon Web Services
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101Itiel Shwartz
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentTemporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentHostedbyConfluent
 
Hardening Kafka Replication
Hardening Kafka Replication Hardening Kafka Replication
Hardening Kafka Replication confluent
 

Tendances (20)

Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin Podval
 
Introduction to Microservices Patterns
Introduction to Microservices PatternsIntroduction to Microservices Patterns
Introduction to Microservices Patterns
 
Reactive stream processing using Akka streams
Reactive stream processing using Akka streams Reactive stream processing using Akka streams
Reactive stream processing using Akka streams
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
 
Patterns of resilience
Patterns of resiliencePatterns of resilience
Patterns of resilience
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Apache Kafka Fundamentals for Architects, Admins and Developers
Apache Kafka Fundamentals for Architects, Admins and DevelopersApache Kafka Fundamentals for Architects, Admins and Developers
Apache Kafka Fundamentals for Architects, Admins and Developers
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdf
 
CRDTs with Akka Distributed Data
CRDTs with Akka Distributed DataCRDTs with Akka Distributed Data
CRDTs with Akka Distributed Data
 
Apache Flink and what it is used for
Apache Flink and what it is used forApache Flink and what it is used for
Apache Flink and what it is used for
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistent
 
Designing Structured Streaming Pipelines—How to Architect Things Right
Designing Structured Streaming Pipelines—How to Architect Things RightDesigning Structured Streaming Pipelines—How to Architect Things Right
Designing Structured Streaming Pipelines—How to Architect Things Right
 
Apache Kafka Security
Apache Kafka Security Apache Kafka Security
Apache Kafka Security
 
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...(BDT403) Best Practices for Building Real-time Streaming Applications with Am...
(BDT403) Best Practices for Building Real-time Streaming Applications with Am...
 
Distributed tracing 101
Distributed tracing 101Distributed tracing 101
Distributed tracing 101
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentTemporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Hardening Kafka Replication
Hardening Kafka Replication Hardening Kafka Replication
Hardening Kafka Replication
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 

En vedette

Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...
Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...
Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...Legacy Typesafe (now Lightbend)
 
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...Lightbend
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka featuresGrzegorz Duda
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Jonas Bonér
 
Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsKonrad Malawski
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Evan Chan
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...Chris Fregly
 

En vedette (8)

Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...
Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...
Reactive Revealed Part 3 of 3: Resiliency, Failures vs Errors, Isolation, Del...
 
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
Akka Revealed: A JVM Architect's Journey From Resilient Actors To Scalable Cl...
 
Zen of Akka
Zen of AkkaZen of Akka
Zen of Akka
 
Advanced akka features
Advanced akka featuresAdvanced akka features
Advanced akka features
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
 
Reactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka StreamsReactive Stream Processing with Akka Streams
Reactive Stream Processing with Akka Streams
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
 

Similaire à Introducing Akka

Scaling software with akka
Scaling software with akkaScaling software with akka
Scaling software with akkascalaconfjp
 
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
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Tomas Doran
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowAll Things Open
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Anna Shymchenko
 
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreTypesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreLegacy Typesafe (now Lightbend)
 
Learn you some Ansible for great good!
Learn you some Ansible for great good!Learn you some Ansible for great good!
Learn you some Ansible for great good!David Lapsley
 
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian GambleClojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian GambleJulian Gamble
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander DibboOpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander DibboOpenNebula Project
 
Modelling Microservices at Spotify - Petter Mahlen
Modelling Microservices at Spotify - Petter MahlenModelling Microservices at Spotify - Petter Mahlen
Modelling Microservices at Spotify - Petter MahlenJ On The Beach
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysManuel Bernhardt
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupMiguel Pastor
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Operational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU SeminarOperational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU SeminarCanturk Isci
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012 Erik Onnen
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And DesignYaroslav Tkachenko
 

Similaire à Introducing Akka (20)

Scaling software with akka
Scaling software with akkaScaling software with akka
Scaling software with akka
 
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
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To Know
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"
 
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and moreTypesafe Reactive Platform: Monitoring 1.0, Commercial features and more
Typesafe Reactive Platform: Monitoring 1.0, Commercial features and more
 
Clustersoftware
ClustersoftwareClustersoftware
Clustersoftware
 
Learn you some Ansible for great good!
Learn you some Ansible for great good!Learn you some Ansible for great good!
Learn you some Ansible for great good!
 
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian GambleClojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander DibboOpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
 
Modelling Microservices at Spotify - Petter Mahlen
Modelling Microservices at Spotify - Petter MahlenModelling Microservices at Spotify - Petter Mahlen
Modelling Microservices at Spotify - Petter Mahlen
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 
Reactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala MeetupReactive applications and Akka intro used in the Madrid Scala Meetup
Reactive applications and Akka intro used in the Madrid Scala Meetup
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Operational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU SeminarOperational Visibiliy and Analytics - BU Seminar
Operational Visibiliy and Analytics - BU Seminar
 
Performance testing material
Performance testing materialPerformance testing material
Performance testing material
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 

Plus de Jonas Bonér

We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?Jonas Bonér
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumJonas Bonér
 
The Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsThe Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsJonas Bonér
 
Cloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessCloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessJonas Bonér
 
Designing Events-first Microservices
Designing Events-first MicroservicesDesigning Events-first Microservices
Designing Events-first MicroservicesJonas Bonér
 
How Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsHow Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsJonas Bonér
 
Reactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleReactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleJonas Bonér
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To MicrosystemsJonas Bonér
 
Without Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersWithout Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersJonas Bonér
 
Life Beyond the Illusion of Present
Life Beyond the Illusion of PresentLife Beyond the Illusion of Present
Life Beyond the Illusion of PresentJonas Bonér
 
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsGo Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsJonas Bonér
 
Reactive Supply To Changing Demand
Reactive Supply To Changing DemandReactive Supply To Changing Demand
Reactive Supply To Changing DemandJonas Bonér
 
Building Reactive Systems with Akka (in Java 8 or Scala)
Building Reactive Systems with Akka (in Java 8 or Scala)Building Reactive Systems with Akka (in Java 8 or Scala)
Building Reactive Systems with Akka (in Java 8 or Scala)Jonas Bonér
 
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
 
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons LearnedBuilding Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons LearnedJonas Bonér
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveJonas Bonér
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMJonas Bonér
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 

Plus de Jonas Bonér (19)

We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?We are drowning in complexity—can we do better?
We are drowning in complexity—can we do better?
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge Continuum
 
The Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native ApplicationsThe Reactive Principles: Design Principles For Cloud Native Applications
The Reactive Principles: Design Principles For Cloud Native Applications
 
Cloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful ServerlessCloudstate—Towards Stateful Serverless
Cloudstate—Towards Stateful Serverless
 
Designing Events-first Microservices
Designing Events-first MicroservicesDesigning Events-first Microservices
Designing Events-first Microservices
 
How Events Are Reshaping Modern Systems
How Events Are Reshaping Modern SystemsHow Events Are Reshaping Modern Systems
How Events Are Reshaping Modern Systems
 
Reactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at ScaleReactive Microsystems: The Evolution of Microservices at Scale
Reactive Microsystems: The Evolution of Microservices at Scale
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To Microsystems
 
Without Resilience, Nothing Else Matters
Without Resilience, Nothing Else MattersWithout Resilience, Nothing Else Matters
Without Resilience, Nothing Else Matters
 
Life Beyond the Illusion of Present
Life Beyond the Illusion of PresentLife Beyond the Illusion of Present
Life Beyond the Illusion of Present
 
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven SystemsGo Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems
 
Reactive Supply To Changing Demand
Reactive Supply To Changing DemandReactive Supply To Changing Demand
Reactive Supply To Changing Demand
 
Building Reactive Systems with Akka (in Java 8 or Scala)
Building Reactive Systems with Akka (in Java 8 or Scala)Building Reactive Systems with Akka (in Java 8 or Scala)
Building Reactive Systems with Akka (in Java 8 or Scala)
 
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
 
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons LearnedBuilding Scalable, Highly Concurrent & Fault Tolerant Systems -  Lessons Learned
Building Scalable, Highly Concurrent & Fault Tolerant Systems - Lessons Learned
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 

Dernier

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Introducing Akka

  • 1. Introducing Jonas Bonér CTO Typesafe
  • 3. Introducing Akka (Áhkká) The name comes from the goddess in the Sami (native swedes) mythology that represented all the wisdom and beauty in the world. It is also the name of a beautiful mountain in Laponia in the north part of Sweden
  • 5. Vision Simpler Concurrency Scalability Fault-tolerance
  • 6. Vision ...with a single unified Programming Model Managed Runtime Open Source Distribution
  • 8. Scale UP & Scale OUT
  • 9. Program at a Higher Level
  • 10. Program at a Higher Level
  • 11. Program at a Higher Level • Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc.
  • 12. Program at a Higher Level • Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. • Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system
  • 13. Program at a Higher Level • Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. • Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system • You get high CPU utilization, low latency, high throughput and scalability - FOR FREE as part of the model
  • 14. Program at a Higher Level • Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. • Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system • You get high CPU utilization, low latency, high throughput and scalability - FOR FREE as part of the model • Proven and superior model for detecting and recovering from errors
  • 17. Distributable by Design • Actors are location transparent & distributable by design
  • 18. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model
  • 19. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model • You get the PERFECT FABRIC for the CLOUD
  • 20. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model • You get the PERFECT FABRIC for the CLOUD - elastic & dynamic
  • 21. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model • You get the PERFECT FABRIC for the CLOUD - elastic & dynamic - fault-tolerant & self-healing
  • 22. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model • You get the PERFECT FABRIC for the CLOUD - elastic & dynamic - fault-tolerant & self-healing - adaptive load-balancing, cluster rebalancing & actor migration
  • 23. Distributable by Design • Actors are location transparent & distributable by design • Scale UP and OUT for free as part of the model • You get the PERFECT FABRIC for the CLOUD - elastic & dynamic - fault-tolerant & self-healing - adaptive load-balancing, cluster rebalancing & actor migration - build extremely loosely coupled and dynamic systems that can change and adapt at runtime
  • 24. Selection of Akka Production Users
  • 25.
  • 28. Let’s use Actors How can we achieve this?
  • 29. What is an Actor?
  • 30. What is an Actor?
  • 31. What is an Actor? • Akka's unit of code organization is called an Actor
  • 32. What is an Actor? • Akka's unit of code organization is called an Actor • Actors helps you create concurrent, scalable and fault-tolerant applications
  • 33. What is an Actor? • Akka's unit of code organization is called an Actor • Actors helps you create concurrent, scalable and fault-tolerant applications • Like Java EE servlets and session beans, Actors is a model for organizing your code that keeps many “policy decisions” separate from the business logic
  • 34. What is an Actor? • Akka's unit of code organization is called an Actor • Actors helps you create concurrent, scalable and fault-tolerant applications • Like Java EE servlets and session beans, Actors is a model for organizing your code that keeps many “policy decisions” separate from the business logic • Actors may be new to many in the Java community, but they are a tried-and-true concept (Hewitt 1973) used for many years in telecom systems with 9 nines uptime
  • 35.
  • 36. Actors can be seen as Virtual Machines (nodes) in Cloud Computing
  • 37.
  • 40.
  • 41. ...that manages their own memory and behavior
  • 42. ...that manages their own memory and behavior
  • 43.
  • 44. Communicates with asynchronous non-blocking messages
  • 45. Communicates with asynchronous non-blocking messages
  • 46.
  • 47. Elastic - grow and shrink on demand
  • 48. Elastic - grow and shrink on demand
  • 49. Elastic - grow and shrink on demand
  • 50. Elastic - grow and shrink on demand
  • 51.
  • 52. Hot deploy - change behavior at runtime
  • 53. Hot deploy - change behavior at runtime
  • 54. Now - if we replace with Actor EVERYTHING will STILL HOLD for both LOCAL and DISTRIBUTED Actors
  • 55. What can I use Actors for?
  • 56. What can I use Actors for? In different scenarios, an Actor may be an alternative to:
  • 57. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread
  • 58. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component
  • 59. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener
  • 60. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener - a singleton or service
  • 61. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener - a singleton or service - a router, load-balancer or pool
  • 62. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener - a singleton or service - a router, load-balancer or pool - a Java EE Session Bean or Message-Driven Bean
  • 63. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener - a singleton or service - a router, load-balancer or pool - a Java EE Session Bean or Message-Driven Bean - an out-of-process service
  • 64. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component - a callback or listener - a singleton or service - a router, load-balancer or pool - a Java EE Session Bean or Message-Driven Bean - an out-of-process service - a Finite State Machine (FSM)
  • 65. So, what is the Actor Model?
  • 66. Carl Hewitt’s definition http://bit.ly/hewitt-on-actors
  • 67. Carl Hewitt’s definition - The fundamental unit of computation that embodies: http://bit.ly/hewitt-on-actors
  • 68. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing http://bit.ly/hewitt-on-actors
  • 69. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage http://bit.ly/hewitt-on-actors
  • 70. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication http://bit.ly/hewitt-on-actors
  • 71. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication - 3 axioms - When an Actor receives a message it can: http://bit.ly/hewitt-on-actors
  • 72. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication - 3 axioms - When an Actor receives a message it can: - Create new Actors http://bit.ly/hewitt-on-actors
  • 73. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication - 3 axioms - When an Actor receives a message it can: - Create new Actors - Send messages to Actors it knows http://bit.ly/hewitt-on-actors
  • 74. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication - 3 axioms - When an Actor receives a message it can: - Create new Actors - Send messages to Actors it knows - Designate how it should handle the next message it receives http://bit.ly/hewitt-on-actors
  • 75. 4 core Actor operations 0. DEFINE 1. CREATE 2. SEND 3. BECOME 4. SUPERVISE
  • 76. 0. DEFINE public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } }
  • 77. 0. DEFINE Define the message(s) the Actor should be able to respond to public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } }
  • 78. 0. DEFINE Define the message(s) the Actor should be able to respond to public class Greeting implements Serializable { public final String who; Define the Actor class public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } }
  • 79. 0. DEFINE Define the message(s) the Actor should be able to respond to public class Greeting implements Serializable { public final String who; Define the Actor class public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } Define the Actor’s behavior }
  • 80. Scala version case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello {}", who) } }
  • 81. 1. CREATE • CREATE - creates a new instance of an Actor • Extremely lightweight (2.7 Million per Gb RAM) • Very strong encapsulation - encapsulates: -  state -  behavior -  message queue • State & behavior is indistinguishable from each other • Only way to observe state is by sending an actor a message and see how it reacts
  • 82. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
  • 83. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } Create an Actor system } } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
  • 84. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } Create an Actor system } Actor configuration } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter");
  • 85. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } Create an Actor system } Actor configuration } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); Give it a name
  • 86. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } Create an Actor system } Actor configuration } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); Create the Actor Give it a name
  • 87. CREATE Actor public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } Create an Actor system } Actor configuration } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); Create the Actor You get an ActorRef back Give it a name
  • 88. Actors can form hierarchies Guardian System Actor
  • 89. Actors can form hierarchies Guardian System Actor system.actorOf(Props[Foo], “Foo”)
  • 90. Actors can form hierarchies Guardian System Actor Foo system.actorOf(Props[Foo], “Foo”)
  • 91. Actors can form hierarchies Guardian System Actor Foo context.actorOf(Props[A], “A”)
  • 92. Actors can form hierarchies Guardian System Actor Foo A context.actorOf(Props[A], “A”)
  • 93. Actors can form hierarchies Guardian System Actor Foo Bar A A C E C B B D
  • 94. Name resolution - like a file-system Guardian System Actor Foo Bar A A C E C B B D
  • 95. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar A A C E C B B D
  • 96. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar /Foo/A A A C E C B B D
  • 97. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar /Foo/A A A C /Foo/A/B E C B B D
  • 98. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar /Foo/A A A C /Foo/A/B E C B B D /Foo/A/D
  • 100. 2. SEND • SEND - sends a message to an Actor
  • 101. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget
  • 102. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • Everything happens Reactively
  • 103. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • Everything happens Reactively - An Actor is passive until a message is sent to it, which triggers something within the Actor
  • 104. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • Everything happens Reactively - An Actor is passive until a message is sent to it, which triggers something within the Actor - Messages is the Kinetic Energy in an Actor system
  • 105. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • Everything happens Reactively - An Actor is passive until a message is sent to it, which triggers something within the Actor - Messages is the Kinetic Energy in an Actor system - Actors can have lots of buffered Potential Energy but can't do anything with it until it is triggered by a message
  • 106. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • Everything happens Reactively - An Actor is passive until a message is sent to it, which triggers something within the Actor - Messages is the Kinetic Energy in an Actor system - Actors can have lots of buffered Potential Energy but can't do anything with it until it is triggered by a message • EVERYTHING is asynchronous and lockless
  • 107. Throughput on a single box +50 million messages per second
  • 108. SEND message public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); greeter.tell(new Greeting("Charlie Parker"));
  • 109. SEND message public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); greeter.tell(new Greeting("Charlie Parker")); Send the message
  • 110. Full example public class Greeting implements Serializable { public final String who; public Greeting(String who) { this.who = who; } } public class GreetingActor extends UntypedActor { LoggingAdapter log = Logging.getLogger(getContext().system(), this); public void onReceive(Object message) throws Exception { if (message instanceof Greeting) log.info("Hello {}", ((Greeting) message).who); } } } ActorSystem system = ActorSystem.create("MySystem"); ActorRef greeter = system.actorOf(new Props(GreetingActor.class), "greeter"); greeter.tell(new Greeting("Charlie Parker"));
  • 111. Scala version case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello {}", who) } } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") greeter tell Greeting("Charlie Parker")
  • 112. Reply class SomeActor extends UntypedActor { void onReceive(Object msg) { if (msg instanceof User) { User user = (User) msg; // reply to sender getSender().tell(“Hi ” + user.name); } } }
  • 113. Scala version class SomeActor extends Actor { def receive = { case User(name) => // reply to sender sender tell (“Hi ” + name) } }
  • 114. Remote deployment Just feed the ActorSystem with this configuration akka { actor { provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = } } } }
  • 115. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { actor { provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = } } } }
  • 116. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = } } } }
  • 117. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = } } Define Remote Path } }
  • 118. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = akka:// } } Define Remote Path } Protocol }
  • 119. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = akka://MySystem } } Define Remote Path } Protocol Actor System }
  • 120. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = akka://MySystem@machine1 } } Define Remote Path } Protocol Actor System Hostname }
  • 121. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = akka://MySystem@machine1:2552 } } Define Remote Path } Protocol Actor System Hostname Port }
  • 122. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { For the Greeter actor { actor provider = akka.remote.RemoteActorRefProvider deployment { /Greeter { remote = akka://MySystem@machine1:2552 } } Define Remote Path } Protocol Actor System Hostname Port } Zero code changes
  • 124. 3. BECOME • BECOME - dynamically redefines Actor’s behavior
  • 125. 3. BECOME • BECOME - dynamically redefines Actor’s behavior • Triggered reactively by receive of message
  • 126. 3. BECOME • BECOME - dynamically redefines Actor’s behavior • Triggered reactively by receive of message • In a type system analogy it is as if the object changed type - changed interface, protocol & implementation
  • 127. 3. BECOME • BECOME - dynamically redefines Actor’s behavior • Triggered reactively by receive of message • In a type system analogy it is as if the object changed type - changed interface, protocol & implementation • Will now react differently to the messages it receives
  • 128. 3. BECOME • BECOME - dynamically redefines Actor’s behavior • Triggered reactively by receive of message • In a type system analogy it is as if the object changed type - changed interface, protocol & implementation • Will now react differently to the messages it receives • Behaviors are stacked & can be pushed and popped
  • 129. Why would I want to do that?
  • 130. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router
  • 131. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router • Implement an FSM (Finite State Machine)
  • 132. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) • Implement graceful degradation
  • 133. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) • Implement graceful degradation • Spawn up (empty) generic Worker processes that can become whatever the Master currently needs
  • 134. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) • Implement graceful degradation • Spawn up (empty) generic Worker processes that can become whatever the Master currently needs • etc. use your imagination
  • 135. Why would I want to do that? • Let a highly contended Actor adaptively transform himself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) • Implement graceful degradation • Spawn up (empty) generic Worker processes that can become whatever the Master currently needs • etc. use your imagination • Very useful once you get the used to it
  • 136. become context.become(new Procedure[Object]() { void apply(Object msg) { // new body if (msg instanceof NewMessage) { NewMessage newMsg = (NewMessage)msg; ... } } });
  • 137. Actor context available become from within an Actor context.become(new Procedure[Object]() { void apply(Object msg) { // new body if (msg instanceof NewMessage) { NewMessage newMsg = (NewMessage)msg; ... } } });
  • 138. Scala version context become { // new body case NewMessage => ... }
  • 140. Routers val router = system.actorOf( Props[SomeActor].withRouter( RoundRobinRouter(nrOfInstances = 5))) Scala API
  • 141. Router + Resizer val resizer = DefaultResizer(lowerBound = 2, upperBound = 15) val router = system.actorOf( Props[ExampleActor1].withRouter( RoundRobinRouter(resizer = Some(resizer)))) Scala API
  • 142. Failure management in Java/C/C# etc.
  • 143. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control
  • 144. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed
  • 145. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread
  • 146. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread • To make things worse - errors do not propagate between threads so there is NO WAY OF EVEN FINDING OUT that something have failed
  • 147. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread • To make things worse - errors do not propagate between threads so there is NO WAY OF EVEN FINDING OUT that something have failed • This leads to DEFENSIVE programming with:
  • 148. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread • To make things worse - errors do not propagate between threads so there is NO WAY OF EVEN FINDING OUT that something have failed • This leads to DEFENSIVE programming with: • Error handling TANGLED with business logic
  • 149. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread • To make things worse - errors do not propagate between threads so there is NO WAY OF EVEN FINDING OUT that something have failed • This leads to DEFENSIVE programming with: • Error handling TANGLED with business logic • SCATTERED all over the code base
  • 150. Failure management in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed • So you need to do all explicit error handling WITHIN this single thread • To make things worse - errors do not propagate between threads so there is NO WAY OF EVEN FINDING OUT that something have failed • This leads to DEFENSIVE programming with: • Error handling TANGLED with business logic • SCATTERED all over the code base We can do better than this!!!
  • 152. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures
  • 153. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures • Error handling in actors is handle by letting Actors monitor (supervise) each other for failure
  • 154. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures • Error handling in actors is handle by letting Actors monitor (supervise) each other for failure • This means that if an Actor crashes, a notification will be sent to his supervisor, who can react upon the failure
  • 155. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures • Error handling in actors is handle by letting Actors monitor (supervise) each other for failure • This means that if an Actor crashes, a notification will be sent to his supervisor, who can react upon the failure • This provides clean separation of processing and error handling
  • 156. ...let’s take a standard OO application
  • 157.
  • 158. Which components have critically important state and explicit error handling?
  • 159.
  • 167. Node 1 Node 2 Error Kernel
  • 168. SUPERVISE Actor Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden.
  • 169. SUPERVISE Actor Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. class Supervisor extends UntypedActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.parse("1 minute"), new Function<Throwable, Directive>() { @Override public Directive apply(Throwable t) { if (t instanceof ArithmeticException) return resume(); else if (t instanceof NullPointerException) return restart(); else return escalate(); } }); @Override public SupervisorStrategy supervisorStrategy() {
  • 170. SUPERVISE Actor class Supervisor extends UntypedActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.parse("1 minute"), new Function<Throwable, Directive>() { @Override public Directive apply(Throwable t) { if (t instanceof ArithmeticException) return resume(); else if (t instanceof NullPointerException) return restart(); else return escalate(); } }); @Override public SupervisorStrategy supervisorStrategy() { return strategy; } ActorRef worker = context.actorOf(new Props(Worker.class)); public void onReceive(Object message) throws Exception { if (message instanceof Integer) worker.forward(message); } }
  • 171. Scala version class Supervisor extends Actor { override val supervisorStrategy = (maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } val worker = context.actorOf(Props[Worker]) def receive = { case n: Int => worker forward n } }
  • 172. Scala version class Supervisor extends Actor { override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } val worker = context.actorOf(Props[Worker]) def receive = { case n: Int => worker forward n } }
  • 173. Scala version class Supervisor extends Actor { override val supervisorStrategy = AllForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } val worker = context.actorOf(Props[Worker]) def receive = { case n: Int => worker forward n } }
  • 174. Manage failure class Worker extends Actor { ... override def preRestart( reason: Throwable, message: Option[Any]) { ... // clean up before restart } override def postRestart(reason: Throwable) { ... // init after restart } } Scala API
  • 176. This was Akka 2.x Well...it’s a start...
  • 177. ...we have much much more
  • 178. ...we have much much more TestKit Cluster FSM IO HTTP/REST EventBus Durable Mailboxes Pub/Sub Camel Microkernel TypedActor SLF4J AMQP ZeroMQ Dataflow Transactors Agents Spring Extensions
  • 179. get it and learn more http://akka.io http://letitcrash.com http://typesafe.com
  • 180. EOF