Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone use websocket instead of gRPC or REST api for intercommunication between microservices?

Websocket has everything that gRPC does, and is implemented the same way.

So is there any example of such system.

If not why?

like image 380
Muhammad Umer Avatar asked Dec 17 '22 22:12

Muhammad Umer


1 Answers

WebSocket is an older standard part of the HTML5 Features, whereas gRPC is a complete remote procedure call mechanism. gRPC uses HTTP/2 under the hood.

That said, comparing gRPC to WebSockets is a bit like apple to oranges. The HTTP/2 vs WebSockets comparison is more interesting in my opinion. Here is a link to one I like: Will WebSocket survive HTTP/2?

On top of the bare communication protocol itself, gRPC handles a lot more. It adds the whole RPC layer. You define everything in a proto file, and the statically typed (depends on the language) client and server codes are generated. HTTP/2 is an implementation detail of gRPC, and actually, it could be implemented using WebSockets, but WebSockets would not add much on top of bare TCP communication (except for the security layer in case of wss://)

WebSockets was more like a workaround for implementing server push back when it was not available in the HTTP/1.1 protocol, and long polling was the only option.

Answering the question: I do not know of any WebSocket based microservice intercommunication framework, but I do use gRPC for this purpose, and it is awesome ;)

like image 195
Sobvan Avatar answered Apr 27 '23 18:04

Sobvan