简体   繁体   English

两个不同主机上的Round Robin Group无法正常工作

[英]Round Robin Group over two different hosts is not working

I am trying to split load over more than one akka actor system. 我正在尝试将负载分配给多个akka actor系统。 Unfortunately the round robin group in not forwarding messages to remote workers. 不幸的是,轮询组没有将消息转发给远程工作者。 I can see that actor is activated, but there is no work done. 我可以看到该actor已激活,但是没有完成任何工作。

the full code is on github 完整的代码在github上

Is there any other setting that I could miss in my configuration? 我的配置中还有其他设置可能会错过吗?

 private void CreateRemoteCrawlerGroup()
        {
            var hostname = "374110044f24";
            var hostname2 = "25b360699a27";

            var remoteAddress2 = Address.Parse($"akka.tcp://DeployTarget@{hostname2}:8090");
            var remoteScope2 = new RemoteScope(remoteAddress2);
            var remoteCrawler1 =
                Context.ActorOf(
            Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
            .WithRouter(new RoundRobinPool(2)) // new DefaultResizer(1, 2, messagesPerResize: 500)
                             .WithDispatcher("my-dispatcher")
            .WithDeploy(Deploy.None.WithScope(remoteScope2)), "a");

            var remoteAddress = Address.Parse($"akka.tcp://DeployTarget@{hostname}:8090");

            var remoteScope = new RemoteScope(remoteAddress);
            var remoteCrawler2 =
                Context.ActorOf(
            Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
            .WithRouter(new RoundRobinPool(2)) // new DefaultResizer(1, 2, messagesPerResize: 500)
                             .WithDispatcher("my-dispatcher")
            .WithDeploy(Deploy.None.WithScope(remoteScope)), "remoteCrawler01");

            var workers = new List<string> { remoteCrawler1.Path.ToString(), remoteCrawler2.Path.ToString() };
            var router = Context.ActorOf(Props.Empty.WithRouter(new RoundRobinGroup(workers)), "some-group");
            _actorDictionary.Add("WebCrawlerActor", router);
        }

the solution was switch to akka cluster and use clustr pool instead 解决方案是切换到akka群集,改用clustr池

  var remoteEcho2 =
                Context.ActorOf(
                    Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
                        .WithRouter(new ClusterRouterPool(new RoundRobinPool(5), new ClusterRouterPoolSettings(5, 1, true, "crawler"))), "WebCrawlerActor2a");

            _actorDictionary.Add("WebCrawlerActor", remoteEcho2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM