Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Rotem Hermon
@margolis20
Actors, Evolved
#dmconf15
Not THAT
kind of actors.
Multithreading
The problem with multi-threaded concurrency
• Shared memory and state
• Race conditions
• Locks and deadlocks
• Blocking c...
Threads are EVIL!
There has to be a
better way…
The Actor Model
• Formalized in 1973 (Carl Hewitt)
• Concurrency by Message Passing
• Avoids problems of threading and loc...
An Actor, Carl Hewitt definition
• The fundamental unit of computation that embodies:
• Processing
• Storage
• Communicati...
An Actor
• Lightweight
• Never shares state
• Communicates through asynchronous messages
• Mailbox buffers incoming messag...
An Actor
• Lightweight
• Never shares state
• Communicates through asynchronous messages
• Mailbox buffers incoming messag...
The Actor Model
• Higher abstraction level
• Simpler concurrent programming model
• Write single-threaded code (easier to ...
(Actors are actually
Nanoservices)
Leading Classic Actor Implementations
• Erlang
• Developed in the late 90s by Ericsson for HA telecom exchanges
• Actors a...
Akka Fundamentals
Actors Contains:
• State
• Behavior
• An actor can “switch” its internal behavior
• Mailbox
• Several ty...
Akka Fundamentals
• Actors form an hierarchical structure
Akka Fundamentals
• Actor Lifecycle
• Actors needs to be created
and destroyed
• Fault handling is done via
supervision hi...
Akka Fundamentals
• Location Transparency
• Actors can be created remotely
• Actors are called via an actor reference, sam...
Akka Fundamentals
• Dispatchers
• Schedules the message delivery to actors (code execution)
• Can be shared across actors
...
Akka Fundamentals
• Routers
• An actor that routes messages to other actors
• Several routing strategies
There has to be a
better way…
Virtual Actors
• A simplified Actors implementation with a higher abstraction
level
• Introduced by Microsoft Research – P...
Virtual Actors
• A Virtual Actor:
always exists
and
never fails
Virtual Actors
Actor types:
• Worker
• An auto-scaling processing unit – multiple instances created by
framework as needed
Virtual Actors
Actor types:
• Single Activation
• Guaranteed to have a single active instance in the cluster
Virtual Actors
Actor types:
• Single Activation
• Guaranteed to have a single active instance in the cluster
• A Stateful ...
Virtual Actor Framework
• A runtime providing virtual “actor space”, analogues to
virtual memory
• Handles Actor placement...
Virtual Actor Framework
Node
Node
Node
Node
Node
Node
Virtual Actor Framework
Virtual Actor Framework
User
#21
User
#73
Game
#254 Game
#33
Virtual Actor Framework
Auto Scaling
Virtual Actor Framework
Auto Scaling
Virtual Actor Framework
Auto Scaling
Virtual Actor Framework
Auto Scaling
Virtual Actor Framework
Failure Recovery
Virtual Actor Framework
Failure Recovery
Virtual Actor Framework
Failure Recovery
Simplified Programming Model
• An Actor is a class, implementing an interface with
asynchronous methods
• The caller of an...
Simplified Programming Model
Simplified Programming Model
Use Cases
• Stateful Services
• Smart Cache
• Modeling objects at scale (games, IoT)
• Protecting resources / Aggregations
Virtual Actor Implementations
• Orleans (.NET)
• Started by Microsoft Research in 2011, in production since 2012
• Service...
Virtual Actors (Orleans)
• Focus on simplicity and
productivity
• Implicit lifecycle, handled by
runtime
• Automatic clust...
Virtual Actors (Orleans)
Choose if:
• Need a simple model for
distributed applications
• Automatic and straightforward
sca...
Thank You!
Rotem Hermon
@margolis20
VP Architecture @ Gigya
Actors evolved- Rotem Hermon
Actors evolved- Rotem Hermon
Nächste SlideShare
Wird geladen in …5
×

Actors evolved- Rotem Hermon

931 Aufrufe

Veröffentlicht am

The actor model is a novel approach to writing concurrent software. It is based on the concept of small computational units communicating through asynchronous message passing, thus allowing concurrency and scalability while negating a lot of the problems of concurrent programming. Though the actor model got some adoption with the Erlang language and the Akka framework, it remained a rather niche approach and has not become a commonly used practice. But this may be changing now with the introduction of “Virtual Actors” - a new abstraction for writing distributed applications. This abstraction was introduced with the Orleans framework by Microsoft and adopted to Java by EA with their Orbit framework. This talk will include a short introduction to the actor model. We will then explore the Virtual Actors model, how it’s different from the classic model, and why it makes distributed application programming a lot simpler.

Veröffentlicht in: Daten & Analysen
  • Als Erste(r) kommentieren

Actors evolved- Rotem Hermon

  1. 1. Rotem Hermon @margolis20 Actors, Evolved #dmconf15
  2. 2. Not THAT kind of actors.
  3. 3. Multithreading
  4. 4. The problem with multi-threaded concurrency • Shared memory and state • Race conditions • Locks and deadlocks • Blocking calls • Hard to understand and maintain • Not easily distributed
  5. 5. Threads are EVIL!
  6. 6. There has to be a better way…
  7. 7. The Actor Model • Formalized in 1973 (Carl Hewitt) • Concurrency by Message Passing • Avoids problems of threading and locking
  8. 8. An Actor, Carl Hewitt definition • The fundamental unit of computation that embodies: • Processing • Storage • Communication • An actor can: • Create new Actors • Send messages to Actors • Designate how to handle the next message
  9. 9. An Actor • Lightweight • Never shares state • Communicates through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time
  10. 10. An Actor • Lightweight • Never shares state • Communicates through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time • Single threaded
  11. 11. The Actor Model • Higher abstraction level • Simpler concurrent programming model • Write single-threaded code (easier to understand) • Concurrency and scale via actor instances • Maximizes CPU utilization • Easy to distribute
  12. 12. (Actors are actually Nanoservices)
  13. 13. Leading Classic Actor Implementations • Erlang • Developed in the late 90s by Ericsson for HA telecom exchanges • Actors are a core language feature • Akka • A JVM (Scala/Java) Actor framework library • Started by Jonas Bonér in 2009 • Became part of Typesafe (company behind Scala) • .NET port in progress since 2014 (Akka.NET)
  14. 14. Akka Fundamentals Actors Contains: • State • Behavior • An actor can “switch” its internal behavior • Mailbox • Several types of mailboxes • Children • An actor is “responsible” for other actors it creates - Supervisor
  15. 15. Akka Fundamentals • Actors form an hierarchical structure
  16. 16. Akka Fundamentals • Actor Lifecycle • Actors needs to be created and destroyed • Fault handling is done via supervision hierarchies • Several available supervision strategies
  17. 17. Akka Fundamentals • Location Transparency • Actors can be created remotely • Actors are called via an actor reference, same for local and remote • Akka Clustering for additional features
  18. 18. Akka Fundamentals • Dispatchers • Schedules the message delivery to actors (code execution) • Can be shared across actors • Several types of dispatchers and configurations
  19. 19. Akka Fundamentals • Routers • An actor that routes messages to other actors • Several routing strategies
  20. 20. There has to be a better way…
  21. 21. Virtual Actors • A simplified Actors implementation with a higher abstraction level • Introduced by Microsoft Research – Project Orleans • Goals: • Make distributed application programming easier • Prefer developer productivity and transparent scalability • “A programming model and runtime for building cloud native services”
  22. 22. Virtual Actors • A Virtual Actor: always exists and never fails
  23. 23. Virtual Actors Actor types: • Worker • An auto-scaling processing unit – multiple instances created by framework as needed
  24. 24. Virtual Actors Actor types: • Single Activation • Guaranteed to have a single active instance in the cluster
  25. 25. Virtual Actors Actor types: • Single Activation • Guaranteed to have a single active instance in the cluster • A Stateful application middle-tier!
  26. 26. Virtual Actor Framework • A runtime providing virtual “actor space”, analogues to virtual memory • Handles Actor placement, activation and GC when needed • Balances resources across the cluster, provides elastic scalability
  27. 27. Virtual Actor Framework Node Node Node Node Node Node
  28. 28. Virtual Actor Framework
  29. 29. Virtual Actor Framework User #21 User #73 Game #254 Game #33
  30. 30. Virtual Actor Framework Auto Scaling
  31. 31. Virtual Actor Framework Auto Scaling
  32. 32. Virtual Actor Framework Auto Scaling
  33. 33. Virtual Actor Framework Auto Scaling
  34. 34. Virtual Actor Framework Failure Recovery
  35. 35. Virtual Actor Framework Failure Recovery
  36. 36. Virtual Actor Framework Failure Recovery
  37. 37. Simplified Programming Model • An Actor is a class, implementing an interface with asynchronous methods • The caller of an Actor uses the actor interface via a proxy • Messaging is transparent and handled by the runtime. Programmers deal with interfaces and methods
  38. 38. Simplified Programming Model
  39. 39. Simplified Programming Model
  40. 40. Use Cases • Stateful Services • Smart Cache • Modeling objects at scale (games, IoT) • Protecting resources / Aggregations
  41. 41. Virtual Actor Implementations • Orleans (.NET) • Started by Microsoft Research in 2011, in production since 2012 • Service high scale services on Azure (Halo 4 cloud services) • Open sourced in January 2015, active community • Orbit (Java) • Developed by BioWare (division of Electronic Arts) • Inspired by Orleans (“not a port but a re-write”) • Powering online game services • Azure Service Fabric (Reliable Actors)
  42. 42. Virtual Actors (Orleans) • Focus on simplicity and productivity • Implicit lifecycle, handled by runtime • Automatic clustering and load balancing • No hierarchy, all actors are directly accessible • Actor interfaces are regular interfaces (standard OOP) Classic Actors (Akka) • Provide full power (exposing complexity) • Explicit lifecycle, handled by programmer • Clustering and load balancing available (but more complex) • Actors are hierarchical and accessible by path • Actors communicates via explicit message classes
  43. 43. Virtual Actors (Orleans) Choose if: • Need a simple model for distributed applications • Automatic and straightforward scaling • Development team with varied levels of experience Classic Actors (Akka) Choose if: • Need full power – complex topologies, fine grain failure handling, dynamic changing of behavior, explicit message handling • Experienced development team
  44. 44. Thank You! Rotem Hermon @margolis20 VP Architecture @ Gigya

×