为什么我应该使用 gRPC 而不是 IPC / 简单的 WebSocket?

huangapple go评论90阅读模式
英文:

Why should I use gRPC instead of IPC / Simple websocket?

问题

我正在为一个微服务系统设计架构,计划目前在一台机器上运行(将来可能进行分布式部署)。
该系统将由使用Node.js、GO和可能是Java编写的服务组成。
Node.js和Java都需要通过GO服务器传递指令并接收结果。

现在,我正在尝试决定是使用IPC管道还是使用gRPC和Protobuf来提升系统性能。

英文:

I'm sketching an architecture for a micro services system, planned to run currently on one machine (maybe distribution in the future).
The system will be composed of services written in both Node.js, GO and might be Java.
Both node.js and Java will need to pass instructions and receive results from the GO server.

Now, I'm trying to decide should I use IPC pipe or ramp up on gRPC and protobuff and use them.

答案1

得分: 1

这些属于不同的抽象级别,并且具有不同的用途,因此问题中的“或”是错误的。你需要同时使用这两种类型(传输和编码),即使你重新实现其中一种。

像匿名管道或命名管道这样的IPC通常被称为传输,它们没有办法对多个指令或结果进行编码(尽管它们可以对字节流进行编码)。

gRPC和protobuf需要一个传输方式,支持多种传输方式,并添加更精细的编码方式(如何表示整数、列表等),可能还有其他更高级的功能。支持对某些内容进行编码的技术通常可以与传输或编码方式嵌套使用,这在与HTTP一起使用的技术中很常见,这可能是有意义的,但可能只是增加了一层而没有实际用途。

英文:

These are on different abstraction levels and have different uses, as such the 'or' in the question is wrong. You will need both types (transport and encoding), even if you reimplement one of them.

IPC like an anonymous or named pipe is usually called a transport, they have no way to encode multiple instructions or results (though they encode a stream of bytes).

gRPC and protobuf need a transport, support multiple transports and add more fine grained encoding (how to represent an integer, a list, etc) and possibly more on top. Technologies that support encoding something can often be nested with a transport or encoding, this is common with technologies that are used together with HTTP, this may make sense but may only add a layer without having a use.

huangapple
  • 本文由 发表于 2017年5月22日 13:04:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/44104991.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定