本文介绍了ZeroMQ +协议缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ZeroMQ常见问题解答页建议使用Google的作为序列化邮件内容的方法.

ZeroMQ FAQ page suggest use of Google's protobuf as a way to serialise message content.

有人看到一个很好的用法示例吗?

Has anyone see a good usage example?

我还需要回答序列化消息的最大优势是什么?" --也许这是我可以不用的东西,并且可以利用更细的管道.

I also need to get the answer to "What is the biggest advantage of serialising messages?" -whether it may be something I can live without and take the advantage of slimmer pipeline.

我非常喜欢.proto文件和protoc编译器的想法.

I quite like the idea of .proto files and the protoc compiler.

此外,似乎还有另一个很棒的工具可以扔到操场上libev,任何欢迎发表评论:)

Also, it seem that another great tool to throw at the playground would be libev, anycomments are welcome :)

推荐答案

如果您100%确信将要通过ZMQ进行通信的程序将始终能够理解彼此的二进制格式(例如,因为它们总是分布在一起,并且无论如何都使用相同的编译器选项进行编译),我看不到序列化增加的开销没有好处.

If you are 100% certain that the programs that are going to communicate over ZMQ will at all times be capable of understanding each other's binary format (eg because they are always distributed together and were all compiled with the same compiler options anyways) I see no benefit to the overhead that's added by serialization.

一旦不满足上述条件(例如在不同主机类型上运行的伙伴程序,用不同语言编写的程序,甚至可能随时间独立发展的伙伴程序-可能导致其原始二进制结构不兼容),序列化就会变成可能是必须的.

As soon as the above condition cannot be satisfied (like partner programs running on different host types, programs written in different languages or even partner programs that can evolve independently in time - which may cause incompatibilities in their raw binary structures) serialization becomes quite probably a must.

如今,似乎每个人和他们的兄弟都在创建序列化解决方案,这可能表明没有合适的解决方案适合所有解决方案. 此页面包含相当完整的基准测试时间,反序列化时间和大小为27( !!)不同的序列化系统.不要跳过该页面的第一段,它显示警告,基准可能会误导".您的应用程序和数据对您很重要,但是在那里显示的数据可能会帮助您缩小要详细研究的选择的范围.

It seems that nowadays everybody and their brother is creating serialization solutions, which may be an indication that there's no one size fits all solution. This page contains a pretty thorough benchmarking of serialization time, deserialization time and sizes for 27 (!!) different serialization systems. Don't skip the first paragraph of that page, it says "Warning, benchmarks can be misleading". Your application, your data are what counts for you, but the data presented there may help you narrow down the choices you want to study in detail.

这篇关于ZeroMQ +协议缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 04:30