同一Actor的许多实例在单独的远程节点上均匀创建



为了可扩展性,我希望将Mapactor实例(在下面命名mapActor)分布在几个远程节点上,例如host1host2host3。我不确定如何在阿卡application.conf中做到这一点,例如

MapReduceSystem {
  include "common"
  akka {
    actor {
      deployment {
        /mapActor {
          router = round-robin
          nr-of-instances = 48
          remote = "akka.tcp://MapReduceSystem@host1:2552,akka.tcp://MapReduceSystem@host2:2552,akka.tcp://MapReduceSystem@host3:2552" 
        }
        /reduceActor {
          remote = "akka.tcp://MapReduceSystem@host1:2552"
          router = round-robin
          nr-of-instances = 1
        }
        /masterActor {
          remote = "akka.tcp://MapReduceSystem@host1:2552"
          nr-of-instances = 1
        }
      }
    }
    remote.enabled-transports = ["akka.remote.netty.tcp"]
    remote.netty.tcp.hostname = "host1"
  }
}

为了完整起见,这是我的common.conf

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote.netty.tcp.port = 0
  remote.log-remote-lifecycle-events = off
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
}  

请注意mapActor的定义,我想提供 3 个主机来创建此 Actor 的实例,每个主机 16 个,但 remote 参数仅占用一个主机。我该怎么做?

据我了解,此配置将对应于系统启动机host1,配置在host2host3上的外观如何?

来自文档

akka {
  actor {
    deployment {
     /serviceA/aggregation {
       router = "round-robin"
       nr-of-instances = 10
       target {
         nodes = ["akka.tcp://app@10.0.0.2:2552", "akka.tcp://app@10.0.0.3:2552"]
       }
      }
    }
  }
}

因此,您需要的不是remote = "a,b,c" target.nodes = ["a","b","c"]

除了 pushy 指出的配置语法问题之外,除了在host1之前host1host2启动系统之外,您无需执行任何操作,以便在启动/user/mapActor时,其路由可以成功部署到它们上。配置取自host1并传输到其他主机,无需进一步配置,也不需要在工作主机上调用actorOf(至少对于正在讨论的路由器不需要)。

相关内容

  • 没有找到相关文章

最新更新