Erlang如何在同一个节点上的进程之间传递消息? [英] How does Erlang pass messages between processes on the same node?

查看:298
本文介绍了Erlang如何在同一个节点上的进程之间传递消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在节点之间,消息(必须)通过TCP / IP传递。但是,通过在同一个节点上运行的进程之间通过什么机制呢?在这种情况下是否使用TCP / IP? Unix域套接字? 内部节点和节点间消息传递之间的性能有什么不同?

Between nodes, message are (must be) passed over TCP/IP. However, by what mechanism are they passed between processes running on the same node? Is TCP/IP used in this case as well? Unix domain sockets? What is the difference in performance between "within node" and "between node" message passing?

推荐答案


通过在同一个节点上运行的进程之间传递什么机制?

by what mechanism are they passed between processes running on the same node?

因为同一节点上的Erlang进程都在单一本机进程BEAM仿真器消息结构简单地复制到接收者的消息队列中。消息结构被复制而不是简单地引用,用于所有标准的无副作用的功能编程原因。

Because Erlang processes on the same node are all running within a single native process — the BEAM emulator — message structures are simply copied into the receiver's message queue. The message structure is copied, rather than simply referenced, for all the standard no-side-effects functional programming reasons.

请参见 erts_send_message() / code> in erts / emulator / beam / erl_message.c 在Erlang源中有更多的细节。在R15B01中,与您的问题最相关的位从980行开始,调用 erts_queue_message()

See erts_send_message() in erts/emulator/beam/erl_message.c in the Erlang sources for more detail. In R15B01, the bits most relevant to your question start at line 980 or so, with the call to erts_queue_message().

如果您确实选择在单个物理机上运行多个BEAM仿真器,那么我会猜测它们之间的消息与不同物理机器之间的消息相同。尽管如此,现在BEAM有很好的SMP支持可能没有什么好的理由。

If you did choose to run multiple BEAM emulators on a single physical machine, I would guess messages get sent between them the same way as between different physical machines. There's probably no good reason to do that now that BEAM has good SMP support, though.


节点内的性能有什么不同? 和节点之间消息传递?

What is the difference in performance between "within node" and "between node" message passing?

您实际硬件上的简单基准对您而言比对其他人的轶事更有用

A simple benchmark on your actual hardware would be more useful to you than anecdotal evidence from others.

然而,如果你想要一般性,观察到内存带宽是大约20 GByte / sec ,而且您不可能在节点之间的网络链路速度超过10 Gbit / s。这意味着,尽管您的实际应用程序与您执行或查找的任何简单基准测试可能存在很多差异,但这些差异可能不会在传输速率上产生一个数量级差异。

If you want generalities, however, observe that memory bandwidths are around 20 GByte/sec these days, and that you're unlikely to have a network link faster than 10 Gbit/sec between nodes. That means that while there may be many differences between your actual application and any simple benchmark you perform or find, these differences probably cannot swamp an order of magnitude difference in transfer rate.

如果您在节点之间仅拥有1 Gbit / s端到端网络链路,则内部网转移可能会比节点间传输速度快两个数量级以上。

If you "only" have a 1 Gbit/sec end-to-end network link between nodes, intranode transfers will probably be over two orders of magnitude faster than internode transfers.

这篇关于Erlang如何在同一个节点上的进程之间传递消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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