Reliable Actors

You must be familiar with the object-oriented programming paradigm which models problems as a number of interacting objects that contain some data which forms the state of the object. The Actor model of computation breaks down problems into a number of Actors which can function independently and interact with each other by messaging.

The Service Fabric Reliable Actors API provides a high-level abstraction for modelling your Microservices as a number of interacting Actors. This framework is based on the Virtual Actor pattern, which was invented by the Microsoft research team and was released with the  codename Orleans.

The Actor pattern has been implemented in multiple languages through various frameworks such as Akka.NET, ActorKit, and Quasar. However, unlike Actors implemented on other platforms, the Actors in Orleans are virtual. The Orleans runtime manages the location and activation of Actors similarly to the way that the virtual memory manager of an operating system manages memory pages. It activates an Actor by creating an in-memory copy (an activation) on a server, and later it may deactivate that activation if it hasn't been used for some time. If a message is sent to the Actor and there is no activation on any server, then the runtime will pick a location and create a new activation there.
You can read more about the Orleans project from the Microsoft Research website at: https://www.microsoft.com/en-us/research/project/orleans-virtual-actors/.

As a general guidance, you should consider using the Actor pattern in the following scenarios:

  • Your system can be described by a number of independent and interactive units (or Actors), each of which can have its own state and logic
  • You do not have significant interaction with external data sources and your queries do not span across the Actors
  • Your Actors can execute as single-threaded components and do not execute blocking I/O operations

The Service Fabric Reliable Actors API is built on top of the Service Fabric Reliable Services programming model and each Reliable Actor service you write is actually a partitioned, stateful Reliable Service. The Actor state can be stored in memory, on disk, or in external storage.

Since the Service Fabric Actors are virtual, they have a perpetual lifetime. When a client needs to talk to an Actor, the Service Fabric will activate the Actor if it has not been activated or if it has been deactivated. After an Actor has been lying unused for some time, the Service Fabric will deactivate it to save resources. We will read more about Reliable Actors later in this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset