如何在 StatefulActor 中实现 "write-behind"

How do I implement "write-behind" in a StatefulActor

Azure Service Fabric documentation 表示:

Actors provide flexibility for the developer to define rich object structures as part of the actors or reference object graphs outside of the actors. In caching terms actors can write-behind or write-through, or we can use different techniques at a member variable granularity.

StatefulActorStatefulActor<T> 而言,如何实现后写以提高状态更改方法的吞吐量?

一种可能的实现方式是将您的变异方法标记为 [Readonly],这样服务结构运行时就不会将 State 持久保存到集群副本。因此,您可以使用您描述的更改修改内存成员变量,成功或失败将很快 returned 到调用代码。在修改成员变量的同时,您将注册一个提醒,该提醒将修改 State 属性 并因此在集群中的副本之间异步分发更改。

您需要考虑在提醒触发之前将 actor 移动到不同节点的可能性,从而导致读取调用 return 从 State [=19= 读取的陈旧数据] 在更新之前。