gRPC

gRPC, which stands for Google Remote Procedure Call, is an open-source framework developed by Google that enables communication between client and server applications using a simple, high-performance, language-agnostic model[8].
It uses HTTP/2 for transport and Protocol Buffers (protobufs) as its Interface Definition Language (IDL), which allows for efficient binary serialization, smaller message sizes, and faster parsing[1][2][3].

The Problem with Client Libraries

• Any communication protocol needs client library for the language of choice
• SOAP Library
• HTTP Client Library
• Hard-to maintain and patch client libraries
• HTTP/1.1, HTTP/2, new features, security etc.

gRPC modes

• Unary RPC -> Simple Request Response
• Server streaming RPC -> Client requests and server streams a large file
• Client streaming RPC -> Client pulls a large file from Server
• Bidirectional streaming PC -> WebRTC, both Client and Server talk to each other

Pros of gRPC

  1. Performance: gRPC uses HTTP/2 and binary serialization, which results in improved performance and reduced latency. It is significantly faster than REST+JSON communication[3:1][1:1].
  2. Language Support: gRPC supports a wide range of programming languages, including Java, C++, Python, C#, Dart, Go, Kotlin, Node.js, Objective-C, PHP, Ruby, and Swift[4].
  3. Streaming: gRPC offers server, client, and bidirectional streaming modes for real-time communication[1:2].
  4. Strongly Typed: gRPC is strongly typed, which can help prevent errors[5].
  5. Built-in Code Generation: gRPC has automated code generation in different programming languages, which can simplify development[3:2].
  6. Multiplexing: gRPC supports multiplexing, which can reduce network delay[4:1].
  7. Cancel Request: Canceling an existing request possible.

Cons of gRPC

  1. Complexity: gRPC can be more complex compared to REST APIs, which may introduce overhead in certain use cases[1:3]. Schema adds complexities.
  2. Lack of Maturity: Compared to other technologies like GraphQL, gRPC is less mature with fewer resources available for developers[3:3].
  3. Browser Support: gRPC may not be fully supported in older browsers[1:4].
  4. Learning Curve: gRPC requires familiarity with Protocol Buffers and HTTP/2, which can be a learning curve for some developers[1:5].
  5. Error handling
  6. No native browser support
  7. Timeouts (pub/sub)

Compared to other network protocols, gRPC is particularly well-suited for high-performance, large-scale distributed applications, especially those involving real-time communication and cross-platform interoperability. However, its complexity and learning curve may make it less suitable for smaller projects or teams without the necessary expertise[5:1][1:6].

Also Read


  1. https://apidog.com/articles/what-is-grpc/ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  2. https://grpc.io/docs/what-is-grpc/introduction/ ↩︎

  3. https://www.altexsoft.com/blog/what-is-grpc/ ↩︎ ↩︎ ↩︎ ↩︎

  4. https://blog.dreamfactory.com/grpc-vs-rest-how-does-grpc-compare-with-traditional-rest-apis/ ↩︎ ↩︎

  5. https://daily.dev/blog/grpc-vs-rest ↩︎ ↩︎

Thoughts 🤔 by Soumendra Kumar Sahoo is licensed under CC BY 4.0