GRPC vs HTTP

Ankit
2 min readJun 8, 2023

--

gRPC is a high-performance remote procedure call (RPC) framework developed by Google. It uses Protocol Buffers (protobufs) for serializing structured data and works over HTTP/2, an evolution of the original HTTP. gRPC can leverage various features of HTTP/2, which uses a binary framing layer over a Stream Control Transmission Protocol (SCTP) or TCP transport.

Here’s an overview of how gRPC works under the hood:

  1. Connection creation: The first step in gRPC communication is to create a connection between the client and server. This connection uses HTTP/2 and can be carried over TCP, which provides reliable, ordered, and error-checked data delivery.
  2. Protocol Buffers: gRPC employs Protocol Buffers (protobufs) as its Interface Definition Language (IDL). This allows services and their data structures to be defined as language-agnostic.
  3. Stub generation: Based on the protobuf definitions, gRPC can generate client and server stubs in several programming languages. These stubs facilitate communication between the client and server using the defined methods and data structures.
  4. Serialization/deserialization: As part of the communication process, gRPC efficiently serializes and deserializes the data using protobufs. This ensures data is transferred in a compact, type-safe, and efficient binary format.
  5. Bi-directional streaming: One of the significant advantages of gRPC is that it supports bi-directional streaming, which allows the client and server to send multiple messages over a single stream without waiting for a response. This is possible using HTTP/2, which supports various concurrent streams between a client and server.6. Flow control: Besides bi-directional streaming, gRPC also benefits from HTTP/2’s flow control mechanisms. This ensures efficient and fair network resource usage, preventing any stream from monopolizing connection bandwidth.

To summarize, gRPC uses TCP as the underlying transport (by default) and communicates over HTTP/2, using protocol buffers for serialization/deserialization. This provides a high-performance, efficient, and flexible framework for client-server communication, and it differs from HTTP mainly in its use of protobufs, HTTP/2, and support for bi-directional streaming.

--

--

Ankit

I write about life. A blockchain enthusiast, coder and problem solver. Learning to be mindful. Looks for something more than happiness