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.

Actor Patterns and NATS - Boulder Meetup


Published on

At the NATS June Meetup in Boulder, CO, Steven Osborne and Charlie Strawn of Workiva present the Actor Model concept their team are using, and some of the work they are doing to connect NATS and Akka.

You can learn more about NATS at

Published in: Technology
  • Be the first to comment

Actor Patterns and NATS - Boulder Meetup

  1. 1. Actor Pattern and NATS Charlie Strawn and Steven Osborne
  2. 2. Basic Outline ● Introduction to Actor Model ● Similarities to decoupled pub-sub ● Simple NATS-Akka connector ● NATS Actor implementation
  3. 3. Actor Model
  4. 4. Actor Model The actor model is comprised of a system of actors. An actor is a primitive that embodies 1. Processing 2. Storage 3. Communication In an actor system everything is an actor. Actor people love the “one ant is no ant” analogy: One actor is no actor - they come in systems.
  5. 5. Actor Model When an actor receives a message it can 1. Send messages to other actors 2. Create new actors 3. Designate the behavior to be used for the next message it receives This is the real key. The actor is always doing work reacting to some message.
  6. 6. Actor Model - Key points ● Actors can live anywhere. ● There is no shared state among actors. Let it crash. ● Each actor has an address at which it receives messages. ● There is a many-to-many relationship between actors and addresses. ● Messages are delivered at most once. ● Actors process messages serially.
  7. 7. Actor Model - Key points ● The model is inherently concurrent (yey!) so keep computation lightweight and consistent ● Throughput is king ● Each actor processes messages serially - so avoid blocking (except for unavoidable ops like I/O) ● The unit of concurrency is actor - so all computation within the actor is serial. If the actor has too much work and needs more processing power it creates and messages other actors.
  8. 8. Good synopsis... If we’ve piqued your interest in actors but find our summary lacking content - check out this video from Carl Hewitt - the original designer of the Actor Model. Or just do the sane thing and search youtube for “the actor model”. It’s the first one.
  9. 9. Akka ● Akka is Java/Scala library that implements the actor model. Akka is especially well suited to an EventBus style implementation of pub sub. http: // ● 1-to-1 Message to Event ● Effective Akka
  10. 10. Ok, great, isn’t this a NATS talk? NATS is clearly not an actor model - it’s a communication protocol. That being said, it upholds many of the basic tenants embraced by the actor model. ● Decoupled sender/receiver (i.e. publisher-subscriber) ● Publishers and subscribers can live anywhere ● Messages are delivered at most once ● Lightweight and high throughput
  11. 11. NATS-Akka Let’s take the low hanging fruit here - we should be able to connect NATS to an existing actor model implementation. Better yet, let’s take the lowest of the fruit - NATS connector framework (in Java) to Akka (also Java). Lets combine the speed and simplicity of NATS with the speed and simplicity of Akka.
  12. 12. NATS-Akka-Connector Demo!
  13. 13. Akka Clustering ● Akka has a built-in clustering module - but it’s based on complicated on somewhat complicated tcp routing configuration. ● With NATS as the communication point between nodes - clustering akka is simple.
  14. 14. Connecting to an actor system is cool, but... What if the actor system was built on top of NATS? Then multi-node would be a cinch. Setup would be quick. Message latency would be low. Actor Systems could span languages (i.e. have java actors that interacts with legacy apis, go actors to do some heavy lifting, and some rust actors to just be awesome).
  15. 15. Let’s try it out Demo!
  16. 16. More work ● Actually implement akka clustering using NATS as the message transport across cluster nodes ● Multi-node go nats-actor implementation ● More languages for nats-actor (maybe rust? Shameless plug…)
  17. 17. Thanks! Some good resources