While REST is great for the public internet, it is slow for internal service-to-service communication because it uses bulky JSON strings. gRPC (Google Remote Procedure Call) uses a binary format called Protocol Buffers (Protobuf) and runs on **HTTP/2**, making it up to 10x faster than REST.
In gRPC, you define your service in a .proto file. The .NET compiler then automatically generates the C# Client and Server code for you. This ensures 100% type safety between services.
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
Q: "Why can't I easily call a gRPC service from a standard web browser like Chrome?"
Architect Answer: "Standard browsers don't have enough control over the HTTP/2 layer to handle the specific 'Trailing Headers' required by gRPC. To use gRPC on the web, you must use a proxy like **gRPC-Web** or an Envoy proxy that translates the browser's HTTP/1.1 calls into gRPC. This is why gRPC is primarily used for **Internal** service-to-service communication behind the firewall, while REST remains the king of the **Public** internet."