grpc(and socket?)

In gRPC, a client application can directly call a method on a server application on a different machine as if it were a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.

 

 

 

gRPC 是基于 HTTP/2 协议的,所以即使他能做到双向通信也会是类似websocket通信。而且grpc本身就是强区分客户端服务端,不为双向通信设计。

和socket相比:

gRPC 最大优势是编码使用protobuf,具备语言兼容性。使用 protocol buffers 的好处,包括高效的序列号,简单的 IDL 以及容易进行接口更新。 --不过反过来讲实际只使用protorbuf编码或者json编码同样可具备语言兼容性。

但是它和socket通信本身就是不同的东西,要解决的问题完全就是不同的。

posted @ 2021-12-09 10:01  dzqabc  阅读(953)  评论(0编辑  收藏  举报