了解何时使用状态的服务,何时依赖于天青服务织物外部持久性 [英] Understanding when to use stateful services and when to rely on external persistance in Azure Service Fabric

查看:120
本文介绍了了解何时使用状态的服务,何时依赖于天青服务织物外部持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花我的夜晚评价的Azure服务面料为我们当前的WebApp更换/ CloudServices叠加,感觉有点不知道如何决定何时服务/参与者与状态应该是有状态的演员,当他们应该是与外部持续状态无国籍者(SQL Azure的,Azure存储和DocumentDB)。我知道这是一个相当新的产品(向公众至少),所以有可能不是在关于这个有很多最佳实践,但我已经通过大多数的documentation 提供微软没有找到一个明确的答复这一点。

I'm spending my evenings evaluating Azure Service Fabric as a replacement for our current WebApps/CloudServices stack, and feel a little bit unsure about how to decide when services/actors with state should be stateful actors, and when they should be stateless actors with externally persisted state (Azure SQL, Azure Storage and DocumentDB). I know this is a fairly new product (to the general public at least), so there's probably not a lot of best practices in regards to this yet, but I've read through most of the documentation made available by Microsoft without finding a definite answer for this.

目前的问题域,我是接近我们的事件店;我们的应用程序的某些部分基于事件采购和CQRS,而且我评价如何通过移动这个事件存储到服务平台的面料。事件存储将会包含大量的时间序列数据,并因为它是我们唯一的真理的来源,而坚持在那里的数据必须是一致的,复制并存储到某种形式的持久存储。

The current problem domain I'm approaching is our event store; parts of our applications are based on event sourcing and CQRS, and I'm evaluating how to move this event store over to the Service Fabric platform. The event store is going to contain a lot time series-data, and as it's our only source of truth for the data being persisted there it must be consistent, replicated and stored to some form of durable storage.

我也考虑过这样做的一个方法是使用状态EventStream男主角;使用事件货源聚集的每个实例存储一个孤立的流内的事件。这意味着有状态的演员可以保持它自己流的所有事件的跟踪,而且我已经满足我的要求,对数据的存储方式(事务,复制和耐用)。然而,一些流可能会变得非常大(几十万,如果不是数百万事件,),而这正是我开始变得不确定。有一个演员有大量的国家意志,我想,对系统性能的影响,当这些大的数据模型需要序列化或从磁盘反序列化。

One way I have considered doing this is with stateful "EventStream" actor; each instance of an aggregate using event sourcing stores its events within an isolated stream. This means the stateful actor could keep track of all the events for its own stream, and I'd have met my requirements as to how the data is stored (transactional, replicated and durable). However, some streams may grow very large (hundreds of thousands, if not millions, of events), and this is where I'm starting to get unsure. Having an actor with a large amount of state will, I imagine, have impacts on the performance of the system when these large data models needs to be serialized to or deserialized from disk.

另一种选择是保留这些无国籍者,并让他们刚刚从像SQL Azure的一些外部存储读取其数据 - 或只是与无状态服务,而不是演员去

Another option is to keep these actors stateless, and have them just read their data from some external storage like Azure SQL - or just go with stateless services instead of actors.

基本上,当是国家量演员/服务太多,你应该开始考虑的处理状态其它方法吗?

Basically, when is the amount of state for an actor/service "too much" and you should start considering other ways of handling state?

此外,本节中的<一个href=\"http://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-actors-anti-patterns/\">Service面料演员设计模式:一些反模式文档离开我有点疑惑:

Also, this section in the Service Fabric Actors design pattern: Some anti-patterns documentation leave me a little bit puzzled:

治疗的Azure服务织物演员作为一个事务处理系统。 Azure的服务面料演员是不是犯基于两相系统提供ACID。如果我们不实现可选的持久性,和演员是在模具运行的机器,其当前状态会去用它。演员将在另一个节点上上来很快,但除非我们已经实现了持续性的支持,国家将不复存在。然而,利用重试,重复过滤,和/或幂设计的,可以实现的可靠性和一致性高的水平。

Treat Azure Service Fabric Actors as a transactional system. Azure Service Fabric Actors is not a two phase commit-based system offering ACID. If we do not implement the optional persistence, and the machine the actor is running on dies, its current state will go with it. The actor will be coming up on another node very fast, but unless we have implemented the backing persistence, the state will be gone. However, between leveraging retries, duplicate filtering, and/or idempotent design, you can achieve a high level of reliability and consistency.

什么是如果我们不实现可选的持久性,指出在这里?我认为,只要您的交易修改状态成功,您的数据保存到持久存储和复制到至少副本的一个子集IM pression下。这一段让我想知道是否有在哪里我的演员中之国/服务将迷路的情况,如果这是我需要处理自己。在IM pression我从文档的其他部分有状态模型得到了似乎抵消这种说法。

What does "if we do not implement the optional persistance" indicate here? I was under the impression that as long as your transaction modifying the state succeeded, your data was persisted to durable storage and replicated to at least a subset of the replicas. This paragraph leaves me wondering if there are situations where state within my actors/services will get lost, and if this is something I need to handle myself. The impression I got from the stateful model in other parts of the documentation seems to counteract this statement.

推荐答案

这是你必须是保持某些中男主角(让我们说什么可以被认为是需要快速热数据状态的一个选项否则对传统的存储基础架构,如SQL Azure的,DocDB,可用)和存储的一切....
这是很难对太多本地状态一般的规则,但是,也许,它有助于思考与热冷数据。
可靠的演员还提供定制StateProvider的能力,所以你也可以考虑实施定制StateProvider(通过执行IActorStateProvider)与您需要与您在数据量方面有要求,更有效的具体政策,延迟,可靠性等(注意:文件仍然是StateProvider界面很小,但我们可以发布一些示例code,如果这是你想追求的东西)。

One option that you have is to keep 'some' of the state in the actor (let's say what could be considered to be hot data that needs to be quickly available) and store everything else on a 'traditional' storage infrastructure such as SQL Azure, DocDB, .... It is difficult to have a general rule about too much local state but, maybe, it helps to think about hot vs. cold data. Reliable Actors also offer the ability to customize the StateProvider so you can also consider implementing a customized StateProvider (by implementing the IActorStateProvider) with the specific policies that you need to be more efficient with the requirements that you have in terms of amount of data, latency, reliability and so on (note: documentation is still very minimal on the StateProvider interface but we can publish some sample code if this is something you want to pursue).

关于反模式:音符更多的是在多个参与者实现交易。可靠的演员提供了一个演员的边界内的数据的可靠性充分保证。由于分布式和松耦合的Actor模型的性质,实施涉及多个参与者的交易并不是一个简单的任务。如果分发交易是一种强烈的需求,可靠的服务编程模型可能是一个更好的选择。

About the anti-patterns: the note is more about implementing transactions across multiple actors. Reliable Actors provides full guarantee on reliability of the data within the boundaries of an actor. Because of the distributed and loosly coupled nature of the Actor model, implementing transactions that involve multiple actors is not a trivial task. If 'distributed' transactions is a strong requirement, the Reliable Services programming model is probably a better fit.

这篇关于了解何时使用状态的服务,何时依赖于天青服务织物外部持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆