Pergunta

I am writing an Akka application and I want to use the Akka Cluster feature that Typsafe provides. I am trying to understand the main difference between Akka Cluster, Akka Cluster Singleton and Akka Cluster Sharding. 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.

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. Is my assumption correct? I am looking for some guidance as well as any example online if you know any.

Foi útil?

Solução

"Stateless actors that could live in any machine" -- this sounds like akka cluster.

"Stateless actors that I want them to live in specific machines" -- this sounds like akka cluster singleton, but you can also use roles

"being able to restart the actor with its previous state if it dies" -- this sounds like Akka Cluster Sharding with akka-persistence.

Outras dicas

Take a look at https://github.com/dnvriend/spray-ba-sharding and https://github.com/dnvriend/spray-ba-singleton for some use case. The akka documentation is actually pretty good. Also look at the activator templates.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top