Azure Service Fabric reliable actors vs reliable s

2020-05-18 06:48发布

问题:

I am new to Azure Service Fabric and the biggest questions I have are

  1. When should I use reliable actors? Give me practical examples please.
  2. When should I use reliable services? Give me practical examples please.

回答1:

Taken a look at the differences:

  • State analogy : Actors work on a single instance of an object graph. Services usually have state for multiple callers.
  • Scope : Actors can’t work alone, because of their size (more like objects).
  • Life-cycle : Actors are only active when used, so more will fit on your available server resources
  • Concurrency : Actors enforce single threaded access
  • State : Actors just modify the aggregate, services work on sets so often use transactions on sets for ACID behavior.
  • Communication : Actors communicate through channels provided by the platform. Services may choose otherwise.
  • Access : Actors in the cluster can’t be reached from the outside by default. You’ll probably need a Service that provides access.

Samples when to use an actor:

  • For every user of your mobile app you could have one actor.
  • For every thermostat that sends information to your application you could have one actor.
  • For every customer of your e-commerce site, you could have one shopping-basket actor.

Create a service in the cases that you are probably used to. Create a reliable service that provides a service for multiple users at once. For example a weather service.



回答2:

I don't mean to use a word to define itself, but use Reliable Actors only if you've determined your problem fits the actor design pattern. Actors are a design pattern much like many of the Gang of Four design patterns. If your problem fits one of the patterns, use it. If it doesn't, it's best not to try to shoehorn your problem into the wrong pattern.

In Service Fabric, Reliable Actors are an implementation of the Virtual Actor pattern. It has certain rules of operation and caveats that go with them. This is a good doc to read to get an idea of how the Reliable Actor framework works and whether or not it meets your requirements: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-actors-platform/

Reliable Actors are in fact just a framework built on top of Reliable Services, so all the same scaling, partitioning, and distribution rule apply.