extreme-tech-seminar.github.io/slides/actors.org

4.3 KiB
Raw Blame History

Actors

Akka Concurrency

Akka Concurrency

/github/extreme-tech-seminar.github.io/media/commit/3562c6f53b542f08824f7ea6acc3ff86c64b2352/slides/akkaCover185x240.png

Akka Concurrency

Derek Wyatt

Topics

  • Concurrency through messaging
  • Concurrency through delegation
  • Delegation for safety
  • Doing one thing at a time
  • Reactive programming

Concurrency through messaging

You send an actor a message that tells it to do something, which it does presumably quickly and well, and then it tells you what it did. You can scale this model out to thousands or millions (or billions?) of actors and many orders of magnitude more messages and your applications are still reasonable, not to mention huge and fast.

Safety

Theres nothing wrong with creating child actors for the sole purpose of putting them in harms way. In fact, its a very good thing. So dont be afraid of giving birth to an actor only to have him meet his ultimate demise micro-seconds later. Hes more than happy to give his life in the service of his parents good.

Doing one thing at a time

Actors only do one thing at a time; thats the model of concurrency. If you want to have more than one thing happen simultaneously, then you need to create more than one actor to do that work.

Reactive programming

Actor programming is reactive programming. Another way to say this is that its event-driven programming. Event-driven programming has been with us for a long time, but its arguably never been epitomized as much as with actor programming. The reason for this is that actors naturally sit there just waiting for something to happen (i.e., waiting for a message). Its not the act of sending a message thats important; its the act of receiving one that really matters.

Designing for Actor Based Systems

Designing for Actor Based Systems

Processes

One process for each truly concurrent activity in the system.

Vending machine activities

  • Putting coins into the slot
  • Handling coins
  • Handling selections
  • Fetching the coke and putting it into the pickup tray
  • Cooling the soda

Organizing processes

  digraph processes {
          graph [bgcolor=transparent,color=white];
          node [style=filled];
          edge [color=white];

          node [shape=box,fillcolor=grey];
          app_sup [label="Supervisor"];
          vending_sup [label="Supervisor"];

          node [shape=ellipse,fillcolor=white];
          cooling [label="Cooling System"];
          selections [label="Handling Selections"];
          fetching [label="Fetching Soda"];

          app_sup -> cooling;
          app_sup -> vending_sup;

          vending_sup -> selections;
          vending_sup -> fetching;
  }

/github/extreme-tech-seminar.github.io/media/commit/3562c6f53b542f08824f7ea6acc3ff86c64b2352/slides/actors-processes.png

Technologies

Technologies

LANGUAGES AND TOOLS

Erlang/OTP

/github/extreme-tech-seminar.github.io/media/commit/3562c6f53b542f08824f7ea6acc3ff86c64b2352/slides/erlang.jpg

Erlang
Provides lightweight processes and transparent distribution
OTP
Provides frameworks for actors and supervisors via callback modules.

Scala + Akka

/github/extreme-tech-seminar.github.io/media/commit/3562c6f53b542f08824f7ea6acc3ff86c64b2352/slides/scala-logo-white.png /github/extreme-tech-seminar.github.io/media/commit/3562c6f53b542f08824f7ea6acc3ff86c64b2352/slides/akka_full_color.png

Scala
A hybrid functional language on the JVM
Akka
a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications