压缩 Erlang 节点之间发送的消息

发布于 2024-11-02 21:20:39 字数 657 浏览 1 评论 0原文

我正在编写一个分布式 Erlang 应用程序,其中多个节点通过带宽有限的网络连接。因此,当不同节点上的进程相互发送消息时,我希望能够最小化通过网络发送的数据包的大小。

来自 http://www.erlang.org/doc/apps/erts/erl_ext_dist。 html,我了解到Erlang分发机制在内部使用erlang:term_to_binary/1,2将Erlang消息转换为通过网络发送的外部二进制格式。现在,term_to_binary/2 支持多个可用于减小二进制文件大小的选项 (http://www.erlang.org/doc/man/erlang.html#term_to_binary-1),包括压缩选项以及选择具有更有效的浮点数编码的次要版本的能力。

我希望能够告诉分发机制每次通过网络发送消息时使用这两个选项。换句话说,我希望能够指定分发机制调用 term_to_binary 的选项列表。但是,我无法找到有关此主题的任何文档。这可以吗?

感谢您的帮助! :)

I am writing a distributed Erlang application where several nodes are connected via a network with limited bandwidth. Thus, I would like to be able to minimize the size of the packets sent across the network when processes on different nodes send each other messages.

From http://www.erlang.org/doc/apps/erts/erl_ext_dist.html, I understand that the Erlang distribution mechanism uses erlang:term_to_binary/1,2 internally to convert Erlang messages to the external binary format that is sent over the network. Now, term_to_binary/2 supports several options that are useful for reducing the size of the binaries (http://www.erlang.org/doc/man/erlang.html#term_to_binary-1), including a compression option as well as the ability to choose a minor version with more efficient encoding of floats.

I would like to be able to tell the distribution mechanism to use both of these options every time it sends a message over the network. In other words, I would like to be able to specify the Options list that the distribution mechanism calls term_to_binary with. However, I have not been able to find any documentation on this subject. Is this possible to do?

Thanks for your help! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百合的盛世恋 2024-11-09 21:20:39

如果我正确理解代码,则消息编码围绕 进行硬编码dist.c/dsig_send() 的第 1565 行,因此您无法在不修补和重新编译模拟器的情况下更改消息的编码方式。

不过,您可以按照此处所述更改消息分发的运营商。有使用 SSL 进行 Erlang 分发的示例。因此,您可以创建一个压缩所有传输消息的连接(也许使用调整后的 SSL 示例也是可能的)。

标准分发模块的示例如下:

If I understand the code correctly, message encoding hardcoded around the line 1565 of dist.c/dsig_send() so you can't change the way messages are encoded without patching and recompiling the emulator.

However you can change the carrier for message distribution as described here. There is an example of use SSL for Erlang distribution. So you can create a connection which compress all transmission messages (maybe it's even possible with tweaked SSL example).

There are few examples of standard distribution modules:

要走干脆点 2024-11-09 21:20:39

您是否在节点之间使用 rpc?还是 OTP 行为?如果是这样,请尝试在发送之前使用 zlib 压缩二进制文件

Are you using rpc from node to node? Or OTP behaviours? if so try to compress with zlib the binary before it is sent

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文