Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Actors and microservices - Can Two Walk Together?

Actors and microservices - Can Two Walk Together?

The Actor Model is an alternative approach to writing concurrent software without the problems introduced by multithreaded concurrency.
“Virtual Actors” are a new development of the actor model, aimed for solving distributed concurrency issues, providing better productivity, and building cloud native scalable architecture.

With the recent trend of moving into microservices based architecture, there is some confusion about Actors, microservices, and how they fit together.

This session will introduce Actors, Virtual Actors, and how they make distributed application programming a lot simpler. We will then explore the idea of building a microservices architecture on top of Actors, how they combine, and some of the lessons learnt at Gigya doing that.

Presented at DevconTLV, March 2016

Rotem Hermon

March 22, 2016
Tweet

More Decks by Rotem Hermon

Other Decks in Programming

Transcript

  1. 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
  2. The Actor Model • Formalized in 1973 (Carl Hewitt) •

    Concurrency by Message Passing • Avoids problems of threading and locking
  3. An Actor • Lightweight • Never shares state • Communicates

    through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time
  4. An Actor • Lightweight • Never shares state • Communicates

    through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time • Single threaded
  5. 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
  6. Virtual Actors • A simplified Actors implementation with a higher

    abstraction level • Introduced by Microsoft Research – Project Orleans • A port to Java – Orbit (by EA)
  7. Virtual Actors • Goals: • Make distributed application programming easier

    • Prefer developer productivity and transparent scalability • “A programming model and runtime for building cloud native services”
  8. Virtual Actors Actor types: • Worker • An auto-scaling processing

    unit – multiple instances created by framework as needed
  9. Virtual Actors Actor types: • Single Activation • Guaranteed to

    have a single active instance in the cluster
  10. Virtual Actors Actor types: • Single Activation • Guaranteed to

    have a single active instance in the cluster • A Stateful application middle-tier!
  11. 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
  12. 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
  13. Actor based microservices Service A Service B ServiceB Interface Actor

    IMyServiceB ServiceB Client ServiceB HTTP Listener JSON over HTTP