同一个Actor的许多实例在不同的远程节点上均匀创建?

时间:2013-10-23 14:32:29

标签: mapreduce akka

对于可伸缩性,我希望Map actor实例(下面名为mapActor)分布在几个远程节点上,例如host1host2host3。我不确定如何在Akka 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上的外观如何?

2 个答案:

答案 0 :(得分:2)

来自documentation

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"]

答案 1 :(得分:2)

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