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

Ed52a75c8cf2f4cb1c2e9d8d161ca771?s=128

Rotem Hermon

March 22, 2016
Tweet

Transcript

  1. Actors, Microservices… Rotem Hermon @margolis20 Can two walk together?

  2. Actors?

  3. Concurrency

  4. Multithreading

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

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

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

    through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time • Single threaded
  10. 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
  11. None
  12. Distributed Concurrency

  13. Distributed Concurrency

  14. Virtual Actors • A simplified Actors implementation with a higher

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

    • Prefer developer productivity and transparent scalability • “A programming model and runtime for building cloud native services”
  16. Virtual Actors • A Virtual Actor: always exists and never

    fails
  17. Virtual Actors Actor types: • Worker • An auto-scaling processing

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

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

    have a single active instance in the cluster • A Stateful application middle-tier!
  20. 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
  21. 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
  22. (Actors are actually Nanoservices)

  23. A single Actors universe?

  24. Back to microservices

  25. Actor based microservices Service A Service B ServiceB Interface Actor

    IMyServiceB
  26. Actor based microservices Service A Service B ServiceB Interface Actor

    IMyServiceB ServiceB HTTP Listener
  27. Actor based microservices Service A Service B ServiceB Interface Actor

    IMyServiceB ServiceB Client ServiceB HTTP Listener JSON over HTTP
  28. None
  29. Thank You! Rotem Hermon @margolis20 VP Architecture @ Gigya