Skip to main content

Command Palette

Search for a command to run...

gRPC: Under the Hood

Updated
3 min readView as Markdown
D
I'm a Software Engineer, who loves AI and Backend development.

The basic idea is:

“How do two different services talk to each other?”

In a modern application, you often have multiple services running independently. One service might need data or functionality from another service, so they need a way to communicate. REST APIs are one common way to do this. gRPC is another approach to service-to-service communication.

  • Introduction:
    When building modern applications, different services often need to communicate with each other. For example, an Order Service might need to communicate with a Payment Service to process a payment. One of the common ways to make this communication happen is through APIs, with REST being a popular choice.

  • But REST isn't the only way services can communicate. This is where gRPC comes in.

  • gRPC is a framework developed by Google that allows applications and services to communicate with each other efficiently. Instead of manually defining HTTP endpoints and exchanging JSON, gRPC lets us define the service and the methods it provides using a contract, and then generates the code required for communication.

  • At first, terms like RPC, Protocol Buffers, stubs, and HTTP/2 can make gRPC seem complicated. But the basic idea is actually quite simple: a client calls a method on a remote service almost as if it were calling a method locally.

  • In this blog, I'll break down how gRPC works, what happens behind the scenes when a gRPC call is made, and how it differs from the REST APIs we commonly use.

  • I’m approaching gRPC from a beginner’s perspective, trying to understand not just what it is, but why it exists and how it actually works. There are quite a few new concepts involved—RPC, Protocol Buffers, HTTP/2, stubs, services, and more—which can initially make gRPC seem complicated. So, instead of starting with all the technical terminology, I’ll try to break it down step by step, starting with the basic idea of how services communicate and gradually getting into what happens behind the scenes.

  • What problem does gRPC solve?

    Before understanding gRPC, it helps to first understand the problem it is trying to solve.

    In a typical application, we often have multiple services that need to communicate with each other. For example, an Order Service might need to call a Payment Service to process a payment. The Order Service needs to send a request, the Payment Service needs to process it, and then it needs to send a response back.

    One common way of doing this is through REST APIs, where services communicate over HTTP using endpoints and usually exchange data in formats such as JSON.

    gRPC takes a different approach. Instead of thinking primarily in terms of URLs and HTTP endpoints, we define the services and the methods they provide. A client can then call one of those methods on a remote server, making the interaction feel similar to calling a normal function.

    This basic idea is what RPC (Remote Procedure Call) is about: calling a procedure or method that is actually executed on another machine or service.

  • To know more, visit-> https://github.com/dhriti250/gRPC-protocol-

Backend

Part 1 of 1