简体   繁体   English

Akka群集,群集分片和群集单例用例

[英]Akka Cluster, Cluster Sharding and Cluster singleton use cases

I am writing an Akka application and I want to use the Akka Cluster feature that Typsafe provides. 我正在编写一个Akka应用程序,我想使用Typsafe提供的Akka群集功能。 I am trying to understand the main difference between Akka Cluster, Akka Cluster Singleton and Akka Cluster Sharding. 我试图了解Akka群集,Akka群集Singleton和Akka群集分片之间的主要区别。 To me, they seem to be providing similar things. 对我来说,他们似乎提供了类似的东西。

In my scenario I want to have a cluster that will have: 在我的场景中,我想要一个具有以下内容的集群:

  • Stateless actors that could live in any machine (I will have a pool of them) 可以生活在任何机器中的无状态参与者(我将拥有他们)
  • Stateless actors that I want them to live in specific machines 我希望他们生活在特定机器中的无状态演员
  • Stateful actors that could live in any machine but I need just one instance of them across the whole cluster and being able to restart the actor with its previous state if it dies. 有状态的actor可以驻留在任何计算机中,但是我只需要它们在整个集群中的一个实例,并且能够在死亡时以其先前状态重新启动actor。

Based on what I have read I would need Akka Cluster for the first kind, Akka Cluster Singleton for the second kind and Akka Cluster Sharding for the third kind. 根据我所读的内容,第一类将需要Akka群集,第二种需要Akka群集Singleton,第三种需要Akka群集分片。 Is my assumption correct? 我的假设正确吗? I am looking for some guidance as well as any example online if you know any. 我正在寻找一些指导以及在线示例(如果您知道的话)。

Take a look at https://github.com/dnvriend/spray-ba-sharding and https://github.com/dnvriend/spray-ba-singleton for some use case. 看一下https://github.com/dnvriend/spray-ba-shardinghttps://github.com/dnvriend/spray-ba-singleton的一些用例。 The akka documentation is actually pretty good. Akka文档实际上非常好。 Also look at the activator templates. 还要看激活器模板。

"Stateless actors that could live in any machine" -- this sounds like akka cluster. “可以在任何机器上生活的无状态演员”-听起来像akka集群。

"Stateless actors that I want them to live in specific machines" -- this sounds like akka cluster singleton, but you can also use roles “我希望他们生活在特定机器中的无状态演员”-听起来像akka群集单例,但您也可以使用角色

"being able to restart the actor with its previous state if it dies" -- this sounds like Akka Cluster Sharding with akka-persistence. “如果死亡,便能够以其先前的状态重新启动参与者” –听起来像是具有akka持久性的Akka群集分片。

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

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