SlideShare ist ein Scribd-Unternehmen logo
1 von 154
Downloaden Sie, um offline zu lesen
Scaling
   software with

              Jonas Bonér
                CTO Typesafe
               Twitter: @jboner




Akka: ソフトウェアをスケールさせる
Scaling
   Scaling
 software with
software with
Scaling
            Scaling
Copyright Ingeborg van Leeuwen




          software with
         software with
Selection of Akka Production Users
Manage System Overload




システムの過負荷を管理する
Automatic Replication & Distribution




   for Fault-tolerance & Scalability

耐障害性とスケーラビリティを自動的に実現
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



生まれながらに分散化されている
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?
   • 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

コードを分割して、並行性、スケーラビリティ、
耐障害性の高いアプリケーションを支援する
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

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
Carl Hewitt’s definition
  -   The fundamental unit of computation that embodies:




               http://bit.ly/hewitt-on-actors

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
Carl Hewitt’s definition
  -   The fundamental unit of computation that embodies:
      -   Processing




                  http://bit.ly/hewitt-on-actors

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
Carl Hewitt’s definition
  -   The fundamental unit of computation that embodies:
      -   Processing

      -   Storage




                    http://bit.ly/hewitt-on-actors

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
Carl Hewitt’s definition
  -   The fundamental unit of computation that embodies:
      -   Processing

      -   Storage

      -   Communication




                    http://bit.ly/hewitt-on-actors

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
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

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
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

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
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

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
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

処理、記憶、通信を行う基礎単位。受信時の 3公理:
新規作成、他のアクターとの通信、次のメッセージ処理の指定
4 core Actor operations
           0. DEFINE
           1. CREATE
           2. SEND
           3. BECOME
           4. SUPERVISE


アクターの4つの主な仕事
0. DEFINE

     case class Greeting(who: String)

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




処理可能なメッセージ、振る舞いの定義
0. DEFINE
                     Define the message(s) the Actor
                      should be able to respond to


     case class Greeting(who: String)

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




処理可能なメッセージ、振る舞いの定義
0. DEFINE
                     Define the message(s) the Actor
                      should be able to respond to

                           Define the Actor class
     case class Greeting(who: String)

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




処理可能なメッセージ、振る舞いの定義
0. DEFINE
                     Define the message(s) the Actor
                      should be able to respond to

                            Define the Actor class
     case class Greeting(who: String)

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


                     Define the Actor’s behavior




処理可能なメッセージ、振る舞いの定義
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
   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")




ActorRef が返ってくる
CREATE Actor
   case class Greeting(who: String)

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

   val system = ActorSystem("MySystem")
   val greeter = system.actorOf(Props[GreetingActor], name = "greeter")




ActorRef が返ってくる
CREATE Actor
   case class Greeting(who: String)

   class GreetingActor extends Actor with ActorLogging {
     def receive = {
       case Greeting(who) Create an Actor system " + who)
                           => log.info("Hello
     }
                                                 Actor configuration
   }

   val system = ActorSystem("MySystem")
   val greeter = system.actorOf(Props[GreetingActor], name = "greeter")




ActorRef が返ってくる
CREATE Actor
   case class Greeting(who: String)

   class GreetingActor extends Actor with ActorLogging {
     def receive = {
       case Greeting(who) Create an Actor system " + who)
                           => log.info("Hello
     }
                                                 Actor configuration
   }

   val system = ActorSystem("MySystem")
   val greeter = system.actorOf(Props[GreetingActor], name = "greeter")



                                                       Give it a name




ActorRef が返ってくる
CREATE Actor
   case class Greeting(who: String)

   class GreetingActor extends Actor with ActorLogging {
     def receive = {
       case Greeting(who) Create an Actor system " + who)
                           => log.info("Hello
     }
                                                 Actor configuration
   }

   val system = ActorSystem("MySystem")
   val greeter = system.actorOf(Props[GreetingActor], name = "greeter")



                                   Create the Actor    Give it a name




ActorRef が返ってくる
CREATE Actor
   case class Greeting(who: String)

   class GreetingActor extends Actor with ActorLogging {
     def receive = {
       case Greeting(who) Create an Actor system " + who)
                           => log.info("Hello
     }
                                                 Actor configuration
   }

   val system = ActorSystem("MySystem")
   val greeter = system.actorOf(Props[GreetingActor], name = "greeter")



                                    Create the Actor
              You get an ActorRef back                 Give it a name




ActorRef が返ってくる
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 is asynchronous and lockless




非同期でノンブロッキングなメッセージの送信
2. SEND
   • SEND - sends a message to an Actor
   • Asynchronous and Non-blocking - Fire-forget
   • EVERYTHING is asynchronous and lockless
   • Everything happens Reactively




非同期でノンブロッキングなメッセージの送信
2. SEND
   • SEND - sends a message to an Actor
   • Asynchronous and Non-blocking - Fire-forget
   • EVERYTHING is asynchronous and lockless
   • 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 is asynchronous and lockless
   • 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 is asynchronous and lockless
   • 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



非同期でノンブロッキングなメッセージの送信
SEND message
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 ! Greeting("Charlie Parker")
SEND message
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 ! Greeting("Charlie Parker")



              Send the message
Full example
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 ! Greeting("Charlie Parker")
Load Balancing
Routers
Routers
     val router =
      system.actorOf(
        Props[SomeActor].withRouter(
         RoundRobinRouter(nrOfInstances = 5)))




ルータを使う
Router + Resizer
    val resizer =
      DefaultResizer(lowerBound = 2, upperBound = 15)

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




リサイザを加える
…or from config
        akka.actor.deployment {
          /path/to/actor {
            router = round-robin
            nr-of-instances = 5
          }
        }




config ファイルからも設定できる
…or from config
       akka.actor.deployment {
         /path/to/actor {
           router = round-robin
           resizer {
             lower-bound = 12
             upper-bound = 15
           }
         }
       }


もしくは設定から
3. BECOME




動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
3. BECOME
 • BECOME - dynamically redefines Actor’s behavior




動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
3. BECOME
 • BECOME - dynamically redefines Actor’s behavior
 • Triggered reactively by receive of message




動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
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




動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
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

動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
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
動的にアクターの振る舞いを再定義
振る舞いはスタックして push/pop することができる
Why would I want to do that?




例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself into
     an Actor Pool or a Router




例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself into
     an Actor Pool or a Router

  • Implement an FSM (Finite State Machine)




例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself into
     an Actor Pool or a Router

  • Implement an FSM (Finite State Machine)
  • Implement graceful degradation




例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself 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




例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself 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

  • Other: Use your imagination!

例) 輻輳時にアクターをルータへ変身、FSM の実装など
Why would I want to do that?
  • Let a highly contended Actor adaptively transform itself 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

  • Other: Use your imagination!
  • Very useful once you get the used to it
例) 輻輳時にアクターをルータへ変身、FSM の実装など
become

context become {
  // new body
  case NewMessage =>
    ...
}
Failure Recovery in Java/C/C# etc.




従来のリカバリはスレッドを用いたもの
Failure Recovery in Java/C/C# etc.
    •   You are given a SINGLE thread of control




従来のリカバリはスレッドを用いたもの
Failure Recovery in Java/C/C# etc.
    •   You are given a SINGLE thread of control
    •   If this thread blows up you are screwed




従来のリカバリはスレッドを用いたもの
Failure Recovery 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 Recovery 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 Recovery 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 Recovery 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 Recovery 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 Recovery 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!!!

従来のリカバリはスレッドを用いたもの
Just

      LET IT CRASH


クラッシュさせろ
クラッシュさせろ
4. SUPERVISE




アクターの故障時は上司の Supervisor が通知され、
対応する。通常処理とエラー処理が分離できる。
4. SUPERVISE
    • SUPERVISE - manage another Actor’s failures




アクターの故障時は上司の Supervisor が通知され、
対応する。通常処理とエラー処理が分離できる。
4. SUPERVISE
    • SUPERVISE - manage another Actor’s failures
    • Error handling in actors is handle by letting Actors
       monitor (supervise) each other for failure




アクターの故障時は上司の Supervisor が通知され、
対応する。通常処理とエラー処理が分離できる。
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




アクターの故障時は上司の Supervisor が通知され、
対応する。通常処理とエラー処理が分離できる。
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


アクターの故障時は上司の Supervisor が通知され、
対応する。通常処理とエラー処理が分離できる。
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.




デフォルトの Supervisor 戦略をオーバーライドできる
SUPERVISE Actor
                   Every single actor has a
                 default supervisor strategy.
                 Which is usually sufficient.
                  But it can be overridden.


 class Supervisor extends Actor {
   override val supervisorStrategy =
                      (maxNrOfRetries = 10, withinTimeRange = 1 minute) {
       case _: ArithmeticException => Resume
       case _: NullPointerException => Restart
       case _: Exception             => Escalate
   }

デフォルトの=Supervisor 戦略をオーバーライドできる
  val worker context.actorOf(Props[Worker])
SUPERVISE Actor
 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
     }
 }




デフォルトの Supervisor 戦略をオーバーライドできる
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
        }
    }




故障の管理
Remoting
Remote deployment
   Just feed the ActorSystem with this configuration



      akka {
        actor {
          provider =    akka.remote.RemoteActorRefProvider
          deployment    {
            /greeter    {
               remote   =
             }
          }
        }
      }




リモート配備: ActorSystem にこの設定を渡すだけ
Remote deployment
   Just feed the ActorSystem with this configuration


                                          Configure a Remote Provider
      akka {
        actor {
          provider =    akka.remote.RemoteActorRefProvider
          deployment    {
            /greeter    {
               remote   =
             }
          }
        }
      }




リモート配備: ActorSystem にこの設定を渡すだけ
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   =
                      }
                   }
               }
            }




リモート配備: ActorSystem にこの設定を渡すだけ
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
               }
            }




リモート配備: ActorSystem にこの設定を渡すだけ
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
            }




リモート配備: ActorSystem にこの設定を渡すだけ
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
            }




リモート配備: ActorSystem にこの設定を渡すだけ
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
            }




リモート配備: ActorSystem にこの設定を渡すだけ
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
            }




リモート配備: ActorSystem にこの設定を渡すだけ
Remote deployment
      Just feed the ActorSystem with this configuration
                       Zero code changes
                                               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
            }




リモート配備: ActorSystem にこの設定を渡すだけ
Remote Lookup


    val greeter = system.actorFor(
        "akka://MySystem@machine1:2552/user/greeter")




リモートアクターを探す
Can you see the problem?



問題に気付いたかな?
Fixed Addresses
    akka {
      actor {
        provider =    akka.remote.RemoteActorRefProvider
        deployment    {
          /greeter    {
             remote   = akka://MySystem@machine1:2552
           }
        }
      }
    }




    val greeter = system.actorFor(
        "akka://MySystem@machine1:2552/user/greeter")




アドレスが決め打ちされている
Akka Cluster
Features
       • Gossip-based Cluster Membership
       • Leader determination
       • Accrual Failure Detector
       • Cluster DeathWatch
       • Cluster-Aware Routers



Gossip-based なクラスタ・メンバーシップ
Enable clustering
   akka {
      actor {
        provider = "akka.cluster.ClusterActorRefProvider"
        ...
      }
     
      cluster {
        seed-nodes = [
          "akka://ClusterSystem@127.0.0.1:2551",
          "akka://ClusterSystem@127.0.0.1:2552"
        ]
    
        auto-down = on
      }
   }




クラスタを使う
Configure a clustered router

      akka.actor.deployment	
  {
      	
  	
  /statsService/workerRouter	
  {
      	
  	
  	
  	
  router	
  =	
  consistent-­‐hashing
      	
  	
  	
  	
  nr-­‐of-­‐instances	
  =	
  100

      	
  	
  	
  	
  cluster	
  {
      	
  	
  	
  	
  	
  	
  enabled	
  =	
  on
      	
  	
  	
  	
  	
  	
  max-nr-of-instances-per-node = 3
      	
  	
  	
  	
  	
  	
  allow-­‐local-­‐routees	
  =	
  on
      	
  	
  	
  	
  }
      	
  	
  }
      }




クラスタ化されたルータの設定
...we have much much more
...we have much much more
              TestKit      FSM
                                        Pub/Sub
Durable Mailboxes
                                  IO
                        Camel
    EventBus
                                           Pooling
                 Typed Channels
Microkernel
                                       SLF4J
              TypedActor
 ZeroMQ                 Dataflow         Transactors
               Agents                  Extensions
get it and learn more
       http://akka.io
    http://letitcrash.com
    http://typesafe.com
E0F

Weitere ähnliche Inhalte

Was ist angesagt?

Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...scalaconfjp
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputPaolo Negri
 
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一scalaconfjp
 
Introduction to akka actors with java 8
Introduction to akka actors with java 8Introduction to akka actors with java 8
Introduction to akka actors with java 8Johan Andrén
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camelkrasserm
 
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介scalaconfjp
 
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
 
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Wooga
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkIan Pointer
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelMykhailo Kotsur
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkEduardo Gonzalez
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Jose Luis Martínez
 
Akka Cluster in Production
Akka Cluster in ProductionAkka Cluster in Production
Akka Cluster in Productionbilyushonak
 
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)petabridge
 

Was ist angesagt? (20)

Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
 
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
 
Introduction to akka actors with java 8
Introduction to akka actors with java 8Introduction to akka actors with java 8
Introduction to akka actors with java 8
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
Why akka
Why akkaWhy akka
Why akka
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
 
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
 
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
 
Scala profiling
Scala profilingScala profiling
Scala profiling
 
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With Spark
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor model
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
 
Akka Cluster in Production
Akka Cluster in ProductionAkka Cluster in Production
Akka Cluster in Production
 
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
 

Andere mochten auch

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
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsJonas Bonér
 
Akka: 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
 
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
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To MicrosystemsJonas Bonér
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 

Andere mochten auch (6)

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
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Akka: 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...
 
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)
 
From Microliths To Microsystems
From Microliths To MicrosystemsFrom Microliths To Microsystems
From Microliths To Microsystems
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 

Ähnlich wie Scaling software with akka

Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Typesafe
 
Орхан Гасимов: "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
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
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)
 
Reactive programming with akka
Reactive programming with akkaReactive programming with akka
Reactive programming with akkaWebdesign Factory
 
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
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software ArchitectureChris F Carroll
 
Nelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional WorldNelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional WorldTimothy Perrett
 
初探 OpenTelemetry - 蒐集遙測數據的新標準
初探 OpenTelemetry - 蒐集遙測數據的新標準初探 OpenTelemetry - 蒐集遙測數據的新標準
初探 OpenTelemetry - 蒐集遙測數據的新標準Marcus Tung
 
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
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Atlassian
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Atlassian
 
Cloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessCloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessLightbend
 
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
 
Building Reactive applications with Akka
Building Reactive applications with AkkaBuilding Reactive applications with Akka
Building Reactive applications with AkkaKnoldus Inc.
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceRobert Munteanu
 

Ähnlich wie Scaling software with akka (20)

Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02Introducingakkajavazone2012 120914094033-phpapp02
Introducingakkajavazone2012 120914094033-phpapp02
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"
 
Clustersoftware
ClustersoftwareClustersoftware
Clustersoftware
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
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
 
Reactive programming with akka
Reactive programming with akkaReactive programming with akka
Reactive programming with akka
 
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
 
Performance testing material
Performance testing materialPerformance testing material
Performance testing material
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software Architecture
 
Nelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional WorldNelson: Rigorous Deployment for a Functional World
Nelson: Rigorous Deployment for a Functional World
 
初探 OpenTelemetry - 蒐集遙測數據的新標準
初探 OpenTelemetry - 蒐集遙測數據的新標準初探 OpenTelemetry - 蒐集遙測數據的新標準
初探 OpenTelemetry - 蒐集遙測數據的新標準
 
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!
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
 
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
Extend Your Use of JIRA by Solving Your Unique Concerns: An Exposé of the New...
 
Akka (1)
Akka (1)Akka (1)
Akka (1)
 
Cloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessCloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful Serverless
 
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)
 
Building Reactive applications with Akka
Building Reactive applications with AkkaBuilding Reactive applications with Akka
Building Reactive applications with Akka
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud ServiceEscape the defaults - Configure Sling like AEM as a Cloud Service
Escape the defaults - Configure Sling like AEM as a Cloud Service
 

Mehr von scalaconfjp

脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~scalaconfjp
 
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会scalaconfjp
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact versionscalaconfjp
 
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...scalaconfjp
 
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...scalaconfjp
 
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan GoyeauScala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeauscalaconfjp
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...scalaconfjp
 
Scala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio BrasilScala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio Brasilscalaconfjp
 
Introduction to GraphQL in Scala
Introduction to GraphQL in ScalaIntroduction to GraphQL in Scala
Introduction to GraphQL in Scalascalaconfjp
 
Safety Beyond Types
Safety Beyond TypesSafety Beyond Types
Safety Beyond Typesscalaconfjp
 
Reactive Kafka with Akka Streams
Reactive Kafka with Akka StreamsReactive Kafka with Akka Streams
Reactive Kafka with Akka Streamsscalaconfjp
 
Reactive microservices with play and akka
Reactive microservices with play and akkaReactive microservices with play and akka
Reactive microservices with play and akkascalaconfjp
 
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメントScalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメントscalaconfjp
 
DWANGO by ドワンゴ
DWANGO by ドワンゴDWANGO by ドワンゴ
DWANGO by ドワンゴscalaconfjp
 
OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.scalaconfjp
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.scalaconfjp
 
統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.scalaconfjp
 
Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.scalaconfjp
 
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.scalaconfjp
 
sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策scalaconfjp
 

Mehr von scalaconfjp (20)

脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
脆弱性対策のためのClean Architecture ~脆弱性に対するレジリエンスを確保せよ~
 
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
Alp x BizReach SaaS事業を営む2社がお互い気になることをゆるゆる聞いてみる会
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
 
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
 
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
Monitoring Reactive Architecture Like Never Before / 今までになかったリアクティブアーキテクチャの監視...
 
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan GoyeauScala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
Scala 3, what does it means for me? / Scala 3って、私にはどんな影響があるの? by Joan Goyeau
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
 
Scala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio BrasilScala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio Brasil
 
Introduction to GraphQL in Scala
Introduction to GraphQL in ScalaIntroduction to GraphQL in Scala
Introduction to GraphQL in Scala
 
Safety Beyond Types
Safety Beyond TypesSafety Beyond Types
Safety Beyond Types
 
Reactive Kafka with Akka Streams
Reactive Kafka with Akka StreamsReactive Kafka with Akka Streams
Reactive Kafka with Akka Streams
 
Reactive microservices with play and akka
Reactive microservices with play and akkaReactive microservices with play and akka
Reactive microservices with play and akka
 
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメントScalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
Scalaに対して意識の低いエンジニアがScalaで何したかの話, by 芸者東京エンターテインメント
 
DWANGO by ドワンゴ
DWANGO by ドワンゴDWANGO by ドワンゴ
DWANGO by ドワンゴ
 
OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.OCTOPARTS by M3, Inc.
OCTOPARTS by M3, Inc.
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.
 
統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.統計をとって高速化する
Scala開発 by CyberZ,Inc.
統計をとって高速化する
Scala開発 by CyberZ,Inc.
 
Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.Short Introduction of Implicit Conversion by TIS, Inc.
Short Introduction of Implicit Conversion by TIS, Inc.
 
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.ビズリーチ x ScalaMatsuri  by BIZREACH, Inc.
ビズリーチ x ScalaMatsuri by BIZREACH, Inc.
 
sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策sbt, past and future / sbt, 傾向と対策
sbt, past and future / sbt, 傾向と対策
 

Scaling software with akka

  • 1. Scaling software with Jonas Bonér CTO Typesafe Twitter: @jboner Akka: ソフトウェアをスケールさせる
  • 2. Scaling Scaling software with software with
  • 3. Scaling Scaling Copyright Ingeborg van Leeuwen software with software with
  • 4. Selection of Akka Production Users
  • 5.
  • 6.
  • 8. Automatic Replication & Distribution for Fault-tolerance & Scalability 耐障害性とスケーラビリティを自動的に実現
  • 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. How can we achieve this? これをどうやって実現するか?
  • 25. How can we achieve this? アクターを使おう
  • 26. Let’s use Actors How can we achieve this? アクターを使おう
  • 27. What is an Actor? コードを分割して、並行性、スケーラビリティ、 耐障害性の高いアプリケーションを支援する
  • 28. What is an Actor? • Akka's unit of code organization is called an Actor コードを分割して、並行性、スケーラビリティ、 耐障害性の高いアプリケーションを支援する
  • 29. What is an Actor? • Akka's unit of code organization is called an Actor • Actors helps you create concurrent, scalable and fault-tolerant applications コードを分割して、並行性、スケーラビリティ、 耐障害性の高いアプリケーションを支援する
  • 30. 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 コードを分割して、並行性、スケーラビリティ、 耐障害性の高いアプリケーションを支援する
  • 31. 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 コードを分割して、並行性、スケーラビリティ、 耐障害性の高いアプリケーションを支援する
  • 32. What can I use Actors for? スレッド、コンポーネント、コールバックなどの代替
  • 33. What can I use Actors for? In different scenarios, an Actor may be an alternative to: スレッド、コンポーネント、コールバックなどの代替
  • 34. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread スレッド、コンポーネント、コールバックなどの代替
  • 35. What can I use Actors for? In different scenarios, an Actor may be an alternative to: - a thread - an object instance or component スレッド、コンポーネント、コールバックなどの代替
  • 36. 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 スレッド、コンポーネント、コールバックなどの代替
  • 37. 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 スレッド、コンポーネント、コールバックなどの代替
  • 38. 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 スレッド、コンポーネント、コールバックなどの代替
  • 39. 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 スレッド、コンポーネント、コールバックなどの代替
  • 40. 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 スレッド、コンポーネント、コールバックなどの代替
  • 41. 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) スレッド、コンポーネント、コールバックなどの代替
  • 42. So, what is the Actor Model? アクターモデルとは何か?
  • 43. Carl Hewitt’s definition http://bit.ly/hewitt-on-actors 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 44. Carl Hewitt’s definition - The fundamental unit of computation that embodies: http://bit.ly/hewitt-on-actors 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 45. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing http://bit.ly/hewitt-on-actors 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 46. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage http://bit.ly/hewitt-on-actors 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 47. Carl Hewitt’s definition - The fundamental unit of computation that embodies: - Processing - Storage - Communication http://bit.ly/hewitt-on-actors 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 48. 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 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 49. 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 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 50. 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 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 51. 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 処理、記憶、通信を行う基礎単位。受信時の 3公理: 新規作成、他のアクターとの通信、次のメッセージ処理の指定
  • 52. 4 core Actor operations 0. DEFINE 1. CREATE 2. SEND 3. BECOME 4. SUPERVISE アクターの4つの主な仕事
  • 53. 0. DEFINE case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } 処理可能なメッセージ、振る舞いの定義
  • 54. 0. DEFINE Define the message(s) the Actor should be able to respond to case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } 処理可能なメッセージ、振る舞いの定義
  • 55. 0. DEFINE Define the message(s) the Actor should be able to respond to Define the Actor class case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } 処理可能なメッセージ、振る舞いの定義
  • 56. 0. DEFINE Define the message(s) the Actor should be able to respond to Define the Actor class case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) => log.info("Hello " + who) } } Define the Actor’s behavior 処理可能なメッセージ、振る舞いの定義
  • 57. 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 新規アクターの作成。強力なカプセル化。 メッセージを送ってその反応を見て状態を観測する。
  • 58. CREATE Actor 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") ActorRef が返ってくる
  • 59. CREATE Actor case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) Create an Actor system " + who) => log.info("Hello } } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") ActorRef が返ってくる
  • 60. CREATE Actor case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) Create an Actor system " + who) => log.info("Hello } Actor configuration } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") ActorRef が返ってくる
  • 61. CREATE Actor case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) Create an Actor system " + who) => log.info("Hello } Actor configuration } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Give it a name ActorRef が返ってくる
  • 62. CREATE Actor case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) Create an Actor system " + who) => log.info("Hello } Actor configuration } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Create the Actor Give it a name ActorRef が返ってくる
  • 63. CREATE Actor case class Greeting(who: String) class GreetingActor extends Actor with ActorLogging { def receive = { case Greeting(who) Create an Actor system " + who) => log.info("Hello } Actor configuration } val system = ActorSystem("MySystem") val greeter = system.actorOf(Props[GreetingActor], name = "greeter") Create the Actor You get an ActorRef back Give it a name ActorRef が返ってくる
  • 64. Actors can form hierarchies Guardian System Actor 階層構造を作ることができる
  • 65. Actors can form hierarchies Guardian System Actor system.actorOf(Props[Foo], “Foo”) 階層構造を作ることができる
  • 66. Actors can form hierarchies Guardian System Actor Foo system.actorOf(Props[Foo], “Foo”) 階層構造を作ることができる
  • 67. Actors can form hierarchies Guardian System Actor Foo context.actorOf(Props[A], “A”) 階層構造を作ることができる
  • 68. Actors can form hierarchies Guardian System Actor Foo A context.actorOf(Props[A], “A”) 階層構造を作ることができる
  • 69. Actors can form hierarchies Guardian System Actor Foo Bar A A C E C B B D 階層構造を作ることができる
  • 70. Name resolution - like a file-system Guardian System Actor Foo Bar A A C E C B B D ファイルシステムのような名前解決
  • 71. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar A A C E C B B D ファイルシステムのような名前解決
  • 72. Name resolution - like a file-system Guardian System Actor /Foo Foo Bar /Foo/A A A C E C B B D ファイルシステムのような名前解決
  • 73. 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 ファイルシステムのような名前解決
  • 74. 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 ファイルシステムのような名前解決
  • 76. 2. SEND • SEND - sends a message to an Actor 非同期でノンブロッキングなメッセージの送信
  • 77. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget 非同期でノンブロッキングなメッセージの送信
  • 78. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • EVERYTHING is asynchronous and lockless 非同期でノンブロッキングなメッセージの送信
  • 79. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • EVERYTHING is asynchronous and lockless • Everything happens Reactively 非同期でノンブロッキングなメッセージの送信
  • 80. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • EVERYTHING is asynchronous and lockless • Everything happens Reactively - An Actor is passive until a message is sent to it, which triggers something within the Actor 非同期でノンブロッキングなメッセージの送信
  • 81. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • EVERYTHING is asynchronous and lockless • 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 非同期でノンブロッキングなメッセージの送信
  • 82. 2. SEND • SEND - sends a message to an Actor • Asynchronous and Non-blocking - Fire-forget • EVERYTHING is asynchronous and lockless • 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 非同期でノンブロッキングなメッセージの送信
  • 83. SEND message 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 ! Greeting("Charlie Parker")
  • 84. SEND message 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 ! Greeting("Charlie Parker") Send the message
  • 85. Full example 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 ! Greeting("Charlie Parker")
  • 88. Routers val router = system.actorOf( Props[SomeActor].withRouter( RoundRobinRouter(nrOfInstances = 5))) ルータを使う
  • 89. Router + Resizer val resizer = DefaultResizer(lowerBound = 2, upperBound = 15) val router = system.actorOf( Props[ExampleActor1].withRouter( RoundRobinRouter(resizer = Some(resizer)))) リサイザを加える
  • 90. …or from config akka.actor.deployment { /path/to/actor { router = round-robin nr-of-instances = 5 } } config ファイルからも設定できる
  • 91. …or from config akka.actor.deployment { /path/to/actor { router = round-robin resizer { lower-bound = 12 upper-bound = 15 } } } もしくは設定から
  • 93. 3. BECOME • BECOME - dynamically redefines Actor’s behavior 動的にアクターの振る舞いを再定義 振る舞いはスタックして push/pop することができる
  • 94. 3. BECOME • BECOME - dynamically redefines Actor’s behavior • Triggered reactively by receive of message 動的にアクターの振る舞いを再定義 振る舞いはスタックして push/pop することができる
  • 95. 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 動的にアクターの振る舞いを再定義 振る舞いはスタックして push/pop することができる
  • 96. 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 動的にアクターの振る舞いを再定義 振る舞いはスタックして push/pop することができる
  • 97. 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 動的にアクターの振る舞いを再定義 振る舞いはスタックして push/pop することができる
  • 98. Why would I want to do that? 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 99. Why would I want to do that? • Let a highly contended Actor adaptively transform itself into an Actor Pool or a Router 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 100. Why would I want to do that? • Let a highly contended Actor adaptively transform itself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 101. Why would I want to do that? • Let a highly contended Actor adaptively transform itself into an Actor Pool or a Router • Implement an FSM (Finite State Machine) • Implement graceful degradation 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 102. Why would I want to do that? • Let a highly contended Actor adaptively transform itself 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 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 103. Why would I want to do that? • Let a highly contended Actor adaptively transform itself 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 • Other: Use your imagination! 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 104. Why would I want to do that? • Let a highly contended Actor adaptively transform itself 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 • Other: Use your imagination! • Very useful once you get the used to it 例) 輻輳時にアクターをルータへ変身、FSM の実装など
  • 105. become context become { // new body case NewMessage => ... }
  • 106. Failure Recovery in Java/C/C# etc. 従来のリカバリはスレッドを用いたもの
  • 107. Failure Recovery in Java/C/C# etc. • You are given a SINGLE thread of control 従来のリカバリはスレッドを用いたもの
  • 108. Failure Recovery in Java/C/C# etc. • You are given a SINGLE thread of control • If this thread blows up you are screwed 従来のリカバリはスレッドを用いたもの
  • 109. Failure Recovery 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 従来のリカバリはスレッドを用いたもの
  • 110. Failure Recovery 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 従来のリカバリはスレッドを用いたもの
  • 111. Failure Recovery 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: 従来のリカバリはスレッドを用いたもの
  • 112. Failure Recovery 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 従来のリカバリはスレッドを用いたもの
  • 113. Failure Recovery 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 従来のリカバリはスレッドを用いたもの
  • 114. Failure Recovery 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!!! 従来のリカバリはスレッドを用いたもの
  • 115. Just LET IT CRASH クラッシュさせろ
  • 117. 4. SUPERVISE アクターの故障時は上司の Supervisor が通知され、 対応する。通常処理とエラー処理が分離できる。
  • 118. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures アクターの故障時は上司の Supervisor が通知され、 対応する。通常処理とエラー処理が分離できる。
  • 119. 4. SUPERVISE • SUPERVISE - manage another Actor’s failures • Error handling in actors is handle by letting Actors monitor (supervise) each other for failure アクターの故障時は上司の Supervisor が通知され、 対応する。通常処理とエラー処理が分離できる。
  • 120. 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 アクターの故障時は上司の Supervisor が通知され、 対応する。通常処理とエラー処理が分離できる。
  • 121. 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 アクターの故障時は上司の Supervisor が通知され、 対応する。通常処理とエラー処理が分離できる。
  • 122. Fault-tolerant onion-layered Error Kernel 玉ねぎのように階層化された耐障害性
  • 129. Node 1 Node 2 Error Kernel
  • 130. SUPERVISE Actor Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. デフォルトの Supervisor 戦略をオーバーライドできる
  • 131. SUPERVISE Actor Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. class Supervisor extends Actor { override val supervisorStrategy = (maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: Exception => Escalate } デフォルトの=Supervisor 戦略をオーバーライドできる val worker context.actorOf(Props[Worker])
  • 132. SUPERVISE Actor 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 } } デフォルトの Supervisor 戦略をオーバーライドできる
  • 133. 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 } } 故障の管理
  • 135. Remote deployment Just feed the ActorSystem with this configuration akka { actor { provider = akka.remote.RemoteActorRefProvider deployment { /greeter { remote = } } } } リモート配備: ActorSystem にこの設定を渡すだけ
  • 136. Remote deployment Just feed the ActorSystem with this configuration Configure a Remote Provider akka { actor { provider = akka.remote.RemoteActorRefProvider deployment { /greeter { remote = } } } } リモート配備: ActorSystem にこの設定を渡すだけ
  • 137. 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 = } } } } リモート配備: ActorSystem にこの設定を渡すだけ
  • 138. 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 } } リモート配備: ActorSystem にこの設定を渡すだけ
  • 139. 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 } リモート配備: ActorSystem にこの設定を渡すだけ
  • 140. 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 } リモート配備: ActorSystem にこの設定を渡すだけ
  • 141. 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 } リモート配備: ActorSystem にこの設定を渡すだけ
  • 142. 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 } リモート配備: ActorSystem にこの設定を渡すだけ
  • 143. Remote deployment Just feed the ActorSystem with this configuration Zero code changes 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 } リモート配備: ActorSystem にこの設定を渡すだけ
  • 144. Remote Lookup val greeter = system.actorFor( "akka://MySystem@machine1:2552/user/greeter") リモートアクターを探す
  • 145. Can you see the problem? 問題に気付いたかな?
  • 146. Fixed Addresses akka { actor { provider = akka.remote.RemoteActorRefProvider deployment { /greeter { remote = akka://MySystem@machine1:2552 } } } } val greeter = system.actorFor( "akka://MySystem@machine1:2552/user/greeter") アドレスが決め打ちされている
  • 148. Features • Gossip-based Cluster Membership • Leader determination • Accrual Failure Detector • Cluster DeathWatch • Cluster-Aware Routers Gossip-based なクラスタ・メンバーシップ
  • 149. Enable clustering akka { actor { provider = "akka.cluster.ClusterActorRefProvider" ... }    cluster { seed-nodes = [ "akka://ClusterSystem@127.0.0.1:2551", "akka://ClusterSystem@127.0.0.1:2552" ]   auto-down = on } } クラスタを使う
  • 150. Configure a clustered router akka.actor.deployment  {    /statsService/workerRouter  {        router  =  consistent-­‐hashing        nr-­‐of-­‐instances  =  100        cluster  {            enabled  =  on            max-nr-of-instances-per-node = 3            allow-­‐local-­‐routees  =  on        }    } } クラスタ化されたルータの設定
  • 151. ...we have much much more
  • 152. ...we have much much more TestKit FSM Pub/Sub Durable Mailboxes IO Camel EventBus Pooling Typed Channels Microkernel SLF4J TypedActor ZeroMQ Dataflow Transactors Agents Extensions
  • 153. get it and learn more http://akka.io http://letitcrash.com http://typesafe.com
  • 154. E0F