Akka群集

编程入门 行业动态 更新时间:2024-10-23 23:34:48
本文介绍了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。我可以看到诸如以下内容的选项,如单例或角色,在这里 letitcrash/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 letitcrash/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群集

本文发布于:2023-11-25 14:09:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Akka

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!