Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya

137 views

Published on

As presented in Codemotion Tel Aviv 2017
http://telaviv2017.codemotionworld.com

Published in: Technology
  • Be the first to comment

Actors and Microservices - Can two walk together? - Rotem Hermon, Gigya

  1. 1. Actors, Microservices… Rotem Hermon @margolis20 Can two walk together?
  2. 2. Actors?
  3. 3. Concurrency
  4. 4. Multithreading
  5. 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. 6. The Actor Model • Formalized in 1973 (Carl Hewitt) • Concurrency by Message Passing • Avoids problems of threading and locking
  7. 7. An Actor • Lightweight • Never shares state • Communicates through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time
  8. 8. An Actor • Lightweight • Never shares state • Communicates through asynchronous messages • Mailbox buffers incoming messages • Processes one message at a time • Single threaded
  9. 9. 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
  10. 10. Distributed Concurrency
  11. 11. Virtual Actors • A simplified Actors implementation with a higher abstraction level • Introduced by Microsoft Research – Project Orleans • A port to Java – Orbit (by EA)
  12. 12. Virtual Actors • Goals: • Make distributed application programming easier • Prefer developer productivity and transparent scalability • “A programming model and runtime for building cloud native services”
  13. 13. Virtual Actors • A Virtual Actor: always exists and never fails
  14. 14. Virtual Actors Actor types: • Worker • An auto-scaling processing unit – multiple instances created by framework as needed
  15. 15. Virtual Actors Actor types: • Single Activation • Guaranteed to have a single active instance in the cluster
  16. 16. Virtual Actors Actor types: • Single Activation • Guaranteed to have a single active instance in the cluster • A Stateful application middle-tier!
  17. 17. A Short Example… URL Shortener Service • Shorten (URI) • Expand (ShortURI)
  18. 18. A Short Example… URL Shortener Service The Classic way shrt.uri Stateless Service DB Cache Fetch from DB Set in Cache Expand Return URL Get From Cache
  19. 19. A Short Example… URL Shortener Service The Virtual Actor way shrt.uri Expand Return URL Virtual Actors Service Worker URLActor (“shrt.uri”) “URL” DB Fetch from DB
  20. 20. A Short Example… URL Shortener Service The Virtual Actor way shrt.uri Expand Return URL Virtual Actors Service Worker URLActor (“shrt.uri”) “URL”
  21. 21. A Short Example… URL Shortener Service The Virtual Actor way shrt.uri Expand Return URL Virtual Actors Service Worker URLActor (“shrt.uri”) “URL” And logic!
  22. 22. 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
  23. 23. 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
  24. 24. Simplified Programming Model
  25. 25. Simplified Programming Model
  26. 26. (Actors are actually Nanoservices)
  27. 27. A single Actors universe?
  28. 28. Back to microservices
  29. 29. Actor based microservices Service A Service B ServiceB Interface Actor IMyServiceB
  30. 30. Actor based microservices Service A Service B ServiceB Interface Actor IMyServiceB ServiceB HTTP Listener
  31. 31. Actor based microservices Service A Service B ServiceB Interface Actor IMyServiceB ServiceB Client ServiceB HTTP Listener JSON over HTTP
  32. 32. Thank You! Rotem Hermon @margolis20 VP Architecture @ Gigya

×