为了可扩展性,我希望将Mapactor实例(在下面命名mapActor
)分布在几个远程节点上,例如host1
,host2
和host3
。我不确定如何在阿卡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
,配置在host2
和host3
上的外观如何?
来自文档
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
之前host1
和host2
启动系统之外,您无需执行任何操作,以便在启动/user/mapActor
时,其路由可以成功部署到它们上。配置取自host1
并传输到其他主机,无需进一步配置,也不需要在工作主机上调用actorOf
(至少对于正在讨论的路由器不需要)。