gRPC: High-Performance RPC with Contracts
gRPC is a typed, high-performance function call between services. Instead of crafting JSON, you define a contract and gRPC handles the efficient binary transport. It's for low-latency microservice communication.
WHY IT EXISTS To solve the performance and ambiguity problems of traditional REST/JSON APIs for internal service communication. Text-based formats are slow to parse and lack a strict, enforceable contract, leading to integration issues. gRPC was built for speed and reliability in server-to-server communication.
THE MENTAL MODEL Imagine a function in your code, but the function's body runs on a different server, possibly written in a different language. You define the function's signature (its name, inputs, and outputs) in a language-neutral file. gRPC then generates all the networking code to make calling that remote function feel exactly like calling a local one.
HOW IT WORKS gRPC uses Protocol Buffers (Protobufs) as its Interface Definition Language (IDL). You define your services and message formats in a .proto file. A compiler then generates data access classes and client/server "stubs" in your target language. These stubs handle serializing your data into a compact binary format and sending it over an efficient HTTP/2 connection. The server receives the binary data, deserializes it, and executes the application logic.
WHEN TO USE IT Use gRPC for high-performance, low-latency communication between microservices, especially in a polyglot environment. It's also excellent for real-time applications requiring bidirectional streaming (e.g., chat, live updates) and for connecting mobile or IoT devices to a backend where network efficiency is key.
WHEN NOT TO USE IT Avoid gRPC for public-facing APIs where browser support and human readability are important. A standard REST/JSON API is far easier for external developers to consume and debug with common tools like curl. The tooling for gRPC is more complex than for simple HTTP APIs.
ONE CANONICAL EXAMPLE A common scenario is an order processing system with separate microservices for user authentication, inventory, and payment. A CreateOrder request might first call the AuthService to validate a user token, then the InventoryService to reserve items, and finally the PaymentService to process payment. Using gRPC ensures these internal calls are fast, reliable, and adhere to a strict, pre-defined contract, preventing data mismatch errors between services.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.