grpc 和 websocket 有什么区别?哪个更适合双向流连接? [英] What is difference between grpc and websocket? Which one is more suitable for bidirectional streaming connection?

查看:210
本文介绍了grpc 和 websocket 有什么区别?哪个更适合双向流连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以双向流的方式开发客户端-服务器应用程序.

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-共存

这篇文章很好地概述了它们.从本质上讲,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆