Advertisement
Beginner ASP.NET Core, gRPC Services

What is gRPC, and what are its main advantages over traditional REST/JSON APIs?

Short answer

gRPC is a high-performance RPC (Remote Procedure Call) framework built on HTTP/2 that uses Protocol Buffers (protobuf) for compact binary serialization and strongly-typed service contracts -- compared to REST/JSON, gRPC offers significantly smaller payload sizes, lower latency…

Save ASP.NET Core mock interview
Advertisement
AModel answer
gRPC is a high-performance RPC (Remote Procedure Call) framework built on HTTP/2 that uses Protocol Buffers (protobuf) for compact binary serialization and strongly-typed service contracts -- compared to REST/JSON, gRPC offers significantly smaller payload sizes, lower latency (thanks to HTTP/2 multiplexing), strongly-typed client/server code generated from a shared .proto contract, and native support for streaming (client, server, and bidirectional), making it well suited for internal microservice-to-microservice communication.
syntax = "proto3";

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}
Real-world example
An internal microservices architecture uses gRPC for service-to-service calls (order service calling inventory service) to benefit from lower latency and strongly-typed contracts, while still exposing a public-facing REST/JSON API for external clients and browsers.
Likely follow-ups
  • Why is gRPC generally unsuitable for direct browser consumption without a proxy?
  • How do you decide between gRPC and REST for a given service boundary?
Related topics