I have searched a lot about the pros and cons of WebSocket and gRPC, but I'm still confused about when to use which one of them for let's say a messenger application. I know their protocols are different, but I'm wondering about a data-driven comparison of the performance and latency of different cases of these two technologies. E.x In a case when many users are gonna maintain their connection vs when people might connect and disconnect numerous times and their overhead.
Asked
Active
Viewed 234 times
0
-
I think that [this](https://stackoverflow.com/a/42465368/11810946) might provide the info you are looking for (and suggest a different technology for your messenger app :-)). It's not really possible to directly compare Websockets and gRPC because they are quite different things; Websockets provides a raw pipe whereas gRPC is a higher level protocol running over HTTP/2 (by default; there are [alternatives](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md)). [This answer](https://stackoverflow.com/a/48113832/11810946) might also useful. – Brits Sep 23 '22 at 01:37
-
Thanks for your reply. It seems like because of the Http2 protocol and its advantages, there is not a real advantage (besides development or browser(?) realtime notification) of WebSockets. I want to find a solid and numeric comparison between these two technologies in different cases. – AMK Sep 23 '22 at 12:54
-
A "solid and numeric comparison" is going to be dependent upon your use-case and how you encode data over Websockets (e.g. multiple connections or multiplex, JSON vs protobuf vs something else, protocols such as [MQTT](https://stackoverflow.com/a/61508298/11810946) etc). Having used both approaches I've standardised on gRPC because I find it simpler (most of the needed code is generated for you ready to use from multiple languages including within the browser) but your mileage may vary. Unfortunately any discussion is will be opinion based because the protocols are not directly comparable. – Brits Sep 23 '22 at 23:52
-
Thnx for your comment. It's true that it depends, and I'll appreciate it if anyone comes up with a comparison with some use cases and encoding. – AMK Oct 02 '22 at 07:48