Akka clustering - force actors to stay on specific machines

独自空忆成欢 提交于 2019-12-11 04:17:37

问题


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.

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.


回答1:


There is currently no feature in Akka which would move your actors around: either you programmatically deploy to a specific machine or you put the deployment into the configuration file. Otherwise it will be created locally as you want.

(Akka may one day get automatic actor tree partitioning, but that is not even specified yet.)




回答2:


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.



来源:https://stackoverflow.com/questions/17196968/akka-clustering-force-actors-to-stay-on-specific-machines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!