Akka群集-迫使参与者停留在特定机器上 [英] Akka clustering - force actors to stay on specific machines

查看:77
本文介绍了Akka群集-迫使参与者停留在特定机器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个akka应用程序,我将在许多机器上进行部署。我希望每个应用程序都可以通过使用分布式发布/订阅事件总线功能来相互通信。

I've got an akka application that I will be deploying on many machines. I want each of these applications to communicate with each others by using the distributed publish/subscribe event bus features.

但是,如果我将系统设置为群集,那么我担心一个应用程序的参与者可能会在与其启动的节点不同的节点上创建。

However, if I set the system up for clustering, then I am worried that actors for one application may be created on a different node to the one they started on.

很重要的一点是,参与者只能在计算机上创建,

It's really important that an actor is only created on the machine that the application it belongs to was started on.

基本上,我不需要参与者的弹性或集群,我只是想要分布式的pub / sub。我可以看到诸如以下内容的选项,如单例或角色,在这里 http://letitcrash.com/tagged/spotlight22

Basically, I don't want the elasticity or the clustering of actors, I just want the distributed pub/sub. I can see options like singleton or roles, mentioned here http://letitcrash.com/tagged/spotlight22, but I wondered what the recommended way to do this is.

推荐答案

我认为这不是使用弹性聚类的最佳方法。但是我们也考虑了同一问题,发现通过实体id的散列(例如数据库碎片)在节点上分布参与者可能是有用的。例如,在每个节点上,我们创建一个 NodeRouterActor ,以将消息代理给多个 WorkerActor 。当我们将消息发送到 NodeRouterActor 时,它将通过键 id%nodeCount 在哈希表中查找来选择端点节点然后端点 NodeRouterActor 代理消息到控制实体的特定 WorkerActor

I think this is not the best way to use elastic clustering. But we also consider on the same issue, and found that it could to be usefull to spread actors over the nodes by hash of entity id (like database shards). For example, on each node we create one NodeRouterActor that proxies messages to multiple WorkerActors. When we send message to NodeRouterActor it selects the end point node by lookuping it in hash-table by key id % nodeCount then the end point NodeRouterActor proxies message to specific WorkerActor which controlls the entity.

这篇关于Akka群集-迫使参与者停留在特定机器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆