Backend

gRPC

A remote procedure call framework on HTTP/2 and Protocol Buffers for fast service-to-service communication.

What it is

gRPC was created at Google. The contract is written in a .proto file and client and server code is generated for many languages: Go, Java, Python, C++, Node, C# and others.

Data is serialized in the compact binary Protocol Buffers format, and HTTP/2 with multiplexing is the transport. Streaming in both directions and deadlines are supported.

The typical use is communication between microservices. Browsers need gRPC-Web or a proxy, so public APIs more often use REST or GraphQL.

Use it when

  • Internal microservice communication with a strict contract.
  • You need bidirectional streaming and low latency.
  • Services in different languages sharing one schema.

Avoid it when

  • A public API for browsers and third-party developers: REST is friendlier.
  • You want human-readable requests and debugging with curl.

Key concepts

Protocol Buffers
The schema language and binary serialization format.
Service / RPC
A description of methods callable remotely.
Streaming
Unary, server, client and bidirectional streams.
Deadline
The maximum time a call may take.

Example

A service contract in a .proto file.

Interview questions

  1. 1. How does gRPC differ from REST?

    gRPC uses binary Protobuf and HTTP/2, generates clients from a contract and supports streaming. REST is text-based and simpler for browsers and public APIs.

  2. 2. What call types does gRPC have?

    Unary (request-response), server streaming, client streaming and bidirectional streaming. All are described in .proto.

  3. 3. How do you evolve a schema without breaking clients?

    Add new fields with new numbers and never reuse old numbers. Mark removed fields as reserved.

Interview questions from the bank

Comparisons with this technology

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).