
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.
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.