Sign in
Log inSign up
Ankeet Maini

128 likes

ยท

1.5K reads

14 comments

Devashish Rana
Devashish Rana
Jun 28, 2021

This is pretty good. I think as a technology, we should focus on the pros and cons, and why was it introduced. I think it was introduced to keep a single library for each client and server, so the changes are centralized, unlike REST.

Pros:

  1. It is fast
  2. It uses http2 under the hood
  3. Single library for each client and server maintained by google

Cons

  1. Protobuf makes the client bulky
  2. No direct use of JSON, it won't make sense for the client to know the schema
  3. No browser support YET
  4. It is new and growing
  5. Proxy Support, as any application deployed is not just simple client and server so, the proxy or gateway layer should understand the protocol as well

I believe this is a pretty good piece of technology for microservices intercommunication as it is fast and can reduce the latency in communication.

4
ยท
ยท5 replies
Ankeet Maini
Ankeet Maini
Author
ยทJun 28, 2021

It has browser support since 2016, if you check the code link mentioned at the end of the page. You can find the web integrated with gRPC service.

bulky-client

  • it doesn't right? It makes you free from manually hand-crafting the http request
  • it generates the stubs only, which know how to connect to the remote service

json

  • there's no json, as the client can directly use the response objects created and use it in app
  • no need to know the format of the serialzed data sent over the wire
2
ยท
Devashish Rana
Devashish Rana
Jun 28, 2021

it's just my opinion when I think of grpc, I really appreciate your article.

I just compared with the following scenario of the rest

  1. you don't need any schema
  2. you don't have to stay fixed with a schema from the client side.
  3. any HTTP request you send does not need to have a prevalidated schema

In the case of grpc, you will need a proto file for each grpc service you want to call to the backend. I meant this when I said bulky.

From Browser support I mean, there is no direct web API that can call the grpc. To call the grpc you will have to follow something like the following

client -> rest endpoint -> grpc endpoint

This was the state when I read about this technology and explored it. I will appreciate it if you can add some resources which can contradict the web API issue.

Thanks for a great article. Happy Coding

1
ยท
Ankeet Maini
Ankeet Maini
Author
ยทJun 28, 2021

Haha, yes I agree there's a bit of ceremony. Generate code and use a grpc-web proxy for the protocol conversions, but overall maintenance wise it will make a lot easier.

1
ยท
T.J.
T.J.
Jul 9, 2021
  • No browser support YET
ยท
Ankeet Maini
Ankeet Maini
Author
ยทJul 9, 2021

there is with a proxy to patch over the differences and even http1 to http2Tomas Y.

github.com/improbable-eng/grpc-web/tree/ma…

ยท
Yong Wei Lun
Yong Wei Lun
Jun 30, 2021

gRPC is just too complex.

2
ยท
ยท2 replies
Ankeet Maini
Ankeet Maini
Author
ยทJul 9, 2021

isn't it easier, as you have now auto-generated stubs for all the available service methods?

this will make the integration between backend and frontend super tight - same contract is used to generate the code on both ends, no more searching the correct payload or api endpoint :)

ยท
Yong Wei Lun
Yong Wei Lun
Jul 12, 2021

Ankeet Maini yeah it may sounds easy, but the complexity is on the generation of stubs. For examples:

  • Whether commit stubs to source code or not
  • When to regenerate when protobuf change
  • Dealing with protobuf import paths hell
  • How to version correctly

etc etc...

ยท
Miloslav ๐Ÿณ๏ธโ€๐ŸŒˆ ๐Ÿฆ‹ Voloskov
Miloslav ๐Ÿณ๏ธโ€๐ŸŒˆ ๐Ÿฆ‹ Voloskov

Cognitive complexity is a thing. gRPC is nice and all, but how many engineers out there actually fluent in it just like in REST? And remember that this number won't grow unless REST is deprecated which is not going to happen.

Though, gRPC is nice for microservices communication.

1
ยท
ยท1 reply
Ankeet Maini
Ankeet Maini
Author
ยทJul 9, 2021

I'll reply with a follow up on how to integrate it with web, and try to drive the point home that with generated stubs, maintenance becomes so much easier! Stay tuned :)

ยท
Aman Saxena
Aman Saxena
Jun 29, 2021

what happens if they add support for http3 in the future BOOM, bye bye REST but still it will take time to adapt in the ecosystem

ยท
T.J.
T.J.
Jul 9, 2021

you're saying REST is only http/1 ? That's not true, the plain text REST protocol is the most futuristic, and no problem working over HTTP/2 or HTTP/3

gRPC is only good use as protocols within datacenter between micro-services, never meant to be called in browser to server and is probably never going to gain support in browsers

ยท
ยท1 reply
Ankeet Maini
Ankeet Maini
Author
ยทJul 9, 2021

so gRPC has benefits from performance level due to protobuf encoding; smaller payloads as well as a clear contract which is tangible and not like REST where things are tied together manually (creation of payload, correct URL, query param vs request body)

ยท