羣集感知路由器:akka集羣感知路由器和akka集羣分片的不同用例?
val router = system.actorOf(ClusterRouterPool( RoundRobinPool(0), ClusterRouterPoolSettings( totalInstances = 20, maxInstancesPerNode = 1, allowLocalRoutees = false, useRole = None ) ).props(Props[Worker]), name = "router")
在這裏,我們可以將消息發送到
router
,該郵件將發送到系列遙控routee演員。集羣分片(不考慮持久性)
class NewShoppers extends Actor { ClusterSharding(context.system).start( "shardshoppers", Props(new Shopper), ClusterShardingSettings(context.system), Shopper.extractEntityId, Shopper.extractShardId ) def proxy = { ClusterSharding(context.system).shardRegion("shardshoppers") } override def receive: Receive = { case msg => proxy forward msg } }
在這裏,我們可以將消息發送到
proxy
,該郵件將發送到一系列的分片演員(又名實體)的。
所以,我的問題是:it seems both 2 methods can make the tasks distribute to a lot of actors. What's the design choice of above two? Which situation need which choice?
那麼,一致的哈希池路由器呢?與Cluster分片有什麼不同? – lagom
只要拓撲結構相同,只要它發生變化,它就會將工作發送到同一節點,因爲散列在整個節點集上,所以它可能開始發送到另一個節點。它不會以任何方式通知路由,所以你仍然不能通過這種方式通過id向演員發表演講。 – johanandren
本文:[在Akka.Cluster應用程序中分佈狀態](https://petabridge.com/blog/akkacluster-state-distribution/?utm_source=tuicool&utm_medium=referral)以及johanandren的回答我的問題。 – lagom