简体   繁体   English

消息传递到另一个节点上的特定进程-Erlang

[英]Message passing to specific process on another node - Erlang

My problem is the following 我的问题是以下

Let's say I have two Erlang nodes A and B on different machines, they were started with the same cookie value, and they're both running the same server app of mine 假设我在不同的机器上有两个Erlang节点A和B,它们以相同的cookie值启动,并且都运行与我相同的服务器应用程序

and let's say there are two users, user1 and user2 假设有两个用户,user1和user2

user1 has been connected to A, user2 has been connected to B user1已连接到A,user2已连接到B

when user (any user) connects to Erlang node (any node, chosen by load balancer), looping function tcp_accept() spawns a separate thread for him and recursively continues , BUT the spawned PID is never registered, neither locally nor globally. 当用户(任何用户)连接到Erlang节点(负载均衡器选择的任何节点)时,循环函数tcp_accept()生成单独的线程并递归继续,但生成的PID永远不会在本地或全局进行注册。 rather i save the node name and PID (local for that node) as a tuple identifying the process, in some DB 相反,我在某些数据库中将节点名称和PID(该节点的本地名称)保存为标识进程的元组

An hour ago i thought that the node name and PID (local for that node name) are two sufficient credentials which let us send messages to that thread from any other distributed node (started with same cookie) 一个小时前,我认为节点名称和PID(该节点名称的本地名称)是两个足够的凭据,可让我们从任何其他分布式节点(以相同的cookie开头)向该线程发送消息。

Now that i've reached this part of task, i can't figure out how to do that 现在我已经完成了任务的这一部分,我不知道该怎么做

Is it actually possible to send message to process running on particular node, knowing only the node name and thread PID (local for that node) ? 实际上是否可以仅在知道节点名称和线程PID(该节点本地)的情况下向特定节点上运行的进程发送消息?

PS. PS。 i don't want to register PIDs because the system is aimed to accept connections from lots of users simultaneously and Erlang tutorial discourages registering every user process, since registered names are atoms which are not garbage collected so this may lead to memory leakage. 我不想注册PID,因为该系统旨在同时接受来自许多用户的连接,并且Erlang教程不鼓励注册每个用户进程,因为注册的名称是原子,不会被垃圾收集,因此可能导致内存泄漏。 rather it suggests storing <username, PID> pairs in some storage 而是建议在某些存储中存储<username, PID>

The servers should keep a trace of any connected user (pid of the "user process", node, nickname ...). 服务器应跟踪任何已连接的用户(“用户进程”的pid,节点,昵称...)。 They also should know each other. 他们也应该互相认识。 When a user A want to connect to another user B, he will do it using its nickname, the request is sent to the local server which in turn look for this nickname locally and on remote servers. 当用户A要连接到另一个用户B时,他将使用其昵称进行连接,该请求将发送到本地服务器,该服务器依次在本地和远程服务器上查找此昵称。 If the search succeed, it will be able to send back the connection information of user B to the user A process. 如果搜索成功,它将能够将用户B的连接信息发送回用户A进程。 Then the "direct" communication can start. 然后可以开始“直接”通信。

This pattern does not look very good since processes can crash, and particularly user processes (disconnection, bad entry, timeout...). 这种模式看起来不太好,因为进程可能会崩溃,尤其是用户进程(断开连接,错误的输入,超时...)。 I think that the usual way is to send messages to a server(s), using logical addresses (nickname for example), and the server is in charge to dispatch, store, retreive... the messages 我认为通常的方法是使用逻辑地址(例如昵称)将消息发送到服务器,然后由服务器负责发送,存储,检索...消息

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

相关问题 在java中实时将IO Process的值传递给另一个类 - passing values of IO Process to another class in real time in java Erlang-将每个“ erlang进程”映射到新的内核线程 - Erlang - map each “erlang process” to new kernel thread Erlang 节点到节点消息传递吞吐量、超时和保证 - Erlang Node to Node Messaging Throughput, Timeouts and guarantees Node.js集群将连接传递给特定工作程序 - Node.js cluster passing connection to specific worker 以编程方式从 Grid 进程生成第二个 Selenium Grid 节点作为另一个进程时出现 ParameterException - ParameterException when spawning second Selenium Grid node as another process from Grid process programmatically 使用SetParent窃取另一个进程的主窗口,但保持消息循环分离 - Using SetParent to steal the main window of another process but keeping the message loops separate 自定义消息传递信号量? - Custom message passing semaphore? 消息传递到多个线程 - Message passing to multiple threads “我有多少链接?”,问一个Erlang进程 - “How many links do I have?”, asks an Erlang process 您如何在 Erlang 中调节并发/相对进程性能? - How do you regulate concurrency/relative process performance in Erlang?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM