简体   繁体   English

适用于长时间运行任务的Azure Service Fabric Actor

[英]Azure service fabric actor for long running tasks

I am very new to Azure Service Fabric. 我是Azure Service Fabric的新手。 From my research I am quite keen in utilizing it for a specific optimization problem scenario. 根据我的研究,我非常热衷于将其用于特定的优化问题方案。 However I do not find any detail information on MSDN to back my findings. 但是,我在MSDN上找不到任何详细信息来支持我的发现。

My requirement is that I have a web API that gets an input and dumped to a database. 我的要求是我有一个Web API,该API可以获取输入并转储到数据库中。 This input is used to run an optimization algorithm which typically takes around 3-5 minutes. 此输入用于运行优化算法,该算法通常需要3-5分钟左右。 There may be multiple requests submitted by users which will need to be processed eventually. 用户提交的多个请求可能最终需要处理。

I currently think spawning up a new ASF reliable actors per optimization input is a good choise. 我目前认为,每次优化输入都会产生一个新的ASF可靠参与者,这是一个不错的选择。 However I am not clear on how ASF functions for such tasks that are long running and not instantaneous. 但是,我不清楚ASF如何对长时间运行且不是瞬时的任务起作用。

Further I am in doubt how my resource utilization within the cluster will be. 此外,我不确定群集中的资源利用率如何。 My end goal is to be able to submit at least a predefined amount of optimization algorithm actors or stateless services when required in parallel. 我的最终目标是能够在并行需要时至少提交预定义数量的优化算法参与者无状态服务。

Really appreciate your technical advice related to the concerns I have. 非常感谢您就我所关心的问题提供技术建议。 Is it actors or stateless that I should consider for this scenario. 对于这种情况,我应该考虑是演员还是无国籍

I think what's essential here is to do the calculations in the background. 我认为这里至关重要的是在后台进行计算。 Service /Actor callers shouldn't be kept waiting while the optimization algorithm runs. 优化算法运行时,服务/演员调用者不应一直等待。

To accomplish this you'd need to take a command, save it somewhere (a Queue would do nicely), return a token to the caller. 为此,您需要执行一条命令,将其保存在某个位置(一个Queue会做得很好),然后将令牌返回给调用方。 The token can be used for querying status/progress. 令牌可用于查询状态/进度。

Doing this in an Actor requires: Actor中执行此操作需要:

  • Using the StateManager to hold a queue, that holds jobs 使用StateManager保留队列,该队列保留作业
  • Registering a timer to process the work. 注册一个计时器来处理工作。
  • Optionally calling another (extra) Actor to report on progress (可选)致电其他(额外)演员以报告进度

Doing this in a Stateless service requires: 无状态服务中执行此操作需要:

  • An external queue (which is an external dependency, that impacts availability) 外部队列(这是一个外部依赖关系,会影响可用性)
  • Optionally an external progress store (可选)外部进度存储

Doing this in a Stateful service (additional choice) requires: 在有状态服务(附加选择)中执行此操作需要:

  • using the StateManager to hold a ReliableQueue . 使用StateManager持有ReliableQueue
  • periodically checking this queue for work from RunAsync . 定期检查此队列中RunAsync工作。
  • Optionally periodically store progress in the StateManager . (可选)定期将进度存储在StateManager

I suspect the service type that's best prepared for this scenario is the Stateful Service. 我怀疑最适合这种情况的服务类型是有状态服务。 Here's a Stateful Service example that queues and processes work. 这是一个有状态服务的示例,它排队和处理工作。

I think a combination of stateful and stateless will be a good solution for your scenario. 我认为有状态和无状态的结合将是您的方案的一个很好的解决方案。 Use the stateful to queue the requests and use the stateless to process (algorithms) the requests. 使用有状态的队列请求,并使用无状态的处理(算法)请求。 The SF cluster will create new instances of the stateless service to other nodes in the cluster if needed based on the load. 如果需要,SF集群将根据负载为集群中的其他节点创建无状态服务的新实例。 The stateful service will be your durable store to store the requests(via reliable queue) and progress(reliable dictionaries). 有状态服务将是您的持久存储,用于存储请求(通过可靠的队列)和进度(可靠的字典)。 The stateful service maintains one primary replicas and two secondary replicas in the cluster. 有状态服务在群集中维护一个主副本和两个辅助副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM