Apache Thrift 和 ZeroMQ 之间的区别

发布于 2024-12-14 05:28:41 字数 175 浏览 4 评论 0原文

据我了解,Apache Thrift 和 ZeroMQ 是属于不同类别的软件,并且很难进行比较,因为这是苹果与橘子的比较。但我不知道为什么它们属于不同的类别。它们不是都用于在不同的服务之间传递数据吗?这些服务可能用不同的语言编写,也可能不是用不同的语言编写的?

什么时候应该使用 Thrift,什么时候应该使用消息队列?

I understand that Apache Thrift and ZeroMQ are softwares belonging to different categories, and it is not easy to do a comparison since it is an apple to orange comparison. But I don't know why they belong to different categories. Aren't they both used to pass data between different services, which may or may not be written in different languages?

When should I use Thrift and when should I use a message queue?

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

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

发布评论

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

评论(3

夏了南城 2024-12-21 05:28:41

它们属于不同的类别,主要是因为它们针对具有不同关注点的不同受众。因此,他们在不同的事情上更擅长。

Apache Thrift 类似于 Google Protocol Buffers 旨在成为一种高级的、相当抽象的方法,用于在不同机器上的进程之间(可能使用不同的语言)发送数据。他们有目的地提供一个 IDL-ish 层来描述消息,可能带有自动或半自动版本控制和可选部分。

另一方面,ZeroMQ 特别是,而不是一般的消息队列(这将是一个完全独立的问题),一切都与速度有关。它们有效地将字节移动到另一端。沿途尽可能少停站。因此,您负责序列化、版本控制或其他对开发人员来说重要的事情。当然,这可能意味着复杂性,特别是当您在不同平台和语言之间进行通信时,但这是缺乏抽象的惩罚的一部分。

选择哪个?取决于你的项目。如果您不需要绝对的原始性能,更高级别的工具包可能会很好地满足您的目的。如果您正在构建高速低延迟应用程序,那么无论如何您最终都会更接近金属。

祝你好运

They belong to different categories primarily because they are targetted at different audiences with different concerns. Therefore they are better at different things.

Apache Thrift similar to Google Protocol Buffers is intended to be high-level, reasonably well abstracted means to send data between processes on different machines, possibly in different languages. They purposefully provide an IDL-ish layer to describe the message, perhaps with automatic or semi-automatic versioning and optional sections.

ZeroMQ specifically on the other hand, not message queues in general (which would be an entirely separate question), is all about speed. They efficiently move bytes to the other end. As few stops along the way as possible. As such, you are responsible for serialization, versioning, or whatever else is important to you the developer. Of course, this can mean complexity, particularly if you are communicating between different platforms and languages, but that's part of the penalty for lack of abstraction.

Which to choose? Depends on your project. If you don't need absolute raw performance, a higher level toolkit will likely serve your purpose just fine. If you are building a high-speed low-latency application, you're going to end up closer to the metal anyways.

Good Luck

我们只是彼此的过ke 2024-12-21 05:28:41

Thrift 定义了如何表示复杂数据,以便可以用不同的语言编写和读取它(因此它有 IDL 来定义将传输的类型)。它还定义了在两个端点之间传输此类格式化消息的简单方法(也称为 thirft 传输)。

另一方面,ZeroMQ 的亮点在于您可以在端点之间传输消息,以获得不同的行为,例如一对一、一对多、多对多,以及对此类传输的速度和可靠性的不同期望。至于消息本身,它只是 ZeroMQ 的一个 blob,应用程序应该找到一种对其进行编码和解码的方法。

因此,如果您有复杂的数据结构但简单的消息传递模式,您可能会倾向于 Thrift 方面。如果您有简单的数据但复杂的消息传递模式,您可能会依赖 ZeroMQ 或类似的东西 (AMQP)。

如果您需要两者,您可以配对使用 THrift 和 ZeroMQ,thrift 格式化消息,ZeroMQ 传输消息。请参阅Amir Haghighat 的回答

Thrift defines how to represent complex data so that it can be written and read by different languages (hence it has IDL to define types that will be transported). It also defines simple means to transport such formatted message between two end points (aka thirft transport).

On the other hand ZeroMQ shines in ways you can transport message between endpoints in order to acquire different behaviors like one to one, one to many, many to many, and different expectations of speed and reliability of such transfers. And as for message itself it is just a blob to ZeroMQ, and apps should find a way to encode decode them.

So if you have complex data structures but simple messaging patterns, you might lean on the thrift side. If you have simple data but complex messaging patterns, you might lean on the ZeroMQ or something like that (AMQP).

And if you need both, you could use THrift and ZeroMQ in pair, thrift to format the message, and ZeroMQ to transport it. See Answer by Amir Haghighat.

七分※倦醒 2024-12-21 05:28:41

Davorin 提到 成对使用 Thrift 和 ZeroMQ,如果您对这种方法感兴趣,请查看 Thrift 代码库并查看 thrift /contrib/zeromq 用于使用 ZermoMQ 的 Thrift 演示。

Davorin mentioned using Thrift and ZeroMQ in pair and in case you're interested in that approach checkout the Thrift codebase and look under thrift/contrib/zeromq for a demo of Thrift using ZermoMQ.

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