grpc和websocket有什么区别?哪一种更适合双向流连接? [英] What is difference between grpc and websocket? Which one is more suitable for bidirectional streaming connection?
问题描述
我想以双向流方式开发客户端-服务器应用程序.
I want to develop a client-server application in a bi-directional streaming manner.
grpc或websocket哪种更合适的技术呢?
what is more suitable technology for this, grpc or websocket?
推荐答案
gRPC并不是真正值得比较的部分,它是gRPC使用HTTP/2,可以肯定地将其与WebSockets进行比较.
gRPC is not really the relevant part for comparison, it's that gRPC uses HTTP/2 which can certainly be compared to WebSockets.
https://www.infoq.com/articles/websocket-and- http2-coexist
本文对它们进行了很好的概述.本质上,HTTP/2是在后台使用服务器推送的客户端/服务器,因此您可以发出请求,而只需停留在该连接上即可侦听更新,而无需轮询.
This article outlines them quite well. Essentially, HTTP/2 is Client/Server with Server Push on the background, so you can make your request and simply stay on that connection listening for updates without the need for polling, for example.
尽管WebSockets由于HTTP/2而没有消失,但对于围绕让我知道何时发生与我刚做的事情有关的更新"的用例,可能不需要使用它们.
Whilst WebSockets are not going away because of HTTP/2, they might not be considered necessary for use cases that center around "let me know when updates happen related to the thing I just did".
这篇关于grpc和websocket有什么区别?哪一种更适合双向流连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!