Recently often heard of an abbreviation: GRPC, but this time for a front-end or not too much contact with micro services for students, may still be relatively strange. Here, I would like to share the process of the author’s gradual impression of GRPC from nothing.

What is the GRPC

Google Home PRC framework, RPC(Remote Procedure Call), that is, Remote Procedure Call. A program can call a function on another service as if it were a local function. But that’s not the point.

confusion

From a front-end developer’s point of view, why use RPC when calling a RESTFUL API can do the same thing?

To reassure

From a reading perspective, RPC can be interpreted as a different style from REST, but there are some similarities. When developing, I usually agree on interface documentation and then convert Swagger into a Typescript API. GRPC will have proto files (note: Proto is short for protocol, not proto. Because the front-end partners are familiar with JS prototype, it is easy to misunderstand the PROto in GRPC, resulting in the understanding of the mask), the general function of the implementation is function definition, parameter transfer and return value these functions. When used, it will be converted into functions used by different languages according to the definition of proto file.

Let’s take this as an interface definition. One is Swagger, one is proto.

One More Thing

I read some references and found that microservices tend to use GRPC rather than REST, mainly for better performance (GPRC uses binary, REST generally uses JSON) and streaming of data. Streaming allows you to not get all of the data before proceeding, as with JSON, but only get some of it before proceeding. There is not much understanding of streaming processing. Only so far.

The above