kdocs
GitHub
T&O - Communication
T&O - Communication
  • Async Communication
    • Kafka
    • RabbitMQ
  • Protocols
    • HTTP
  • Sync Communication
    • REST
    • GraphQL
    • gRPC
      • Protocol Buffers
Powered by GitBook
On this page
  • About
  • RPC (Remote Procedure Call)
  • Communication Types
  • Unary
  • Server Streaming
  • Client Streaming
  • Bi Directional Streaming
  • REST vs gRPC
  1. Sync Communication

gRPC

A RPC framework to expose your application endpoints

PreviousGraphQLNextProtocol Buffers

Last updated 6 months ago

About

It is a framework for building robust and scalable communication between server applications.

Ideal for:

  • Microservices. (Communication between services)

  • Backend. (server-to-server communication)

  • Mobile. (mobile-to-backend communication)

Browsers are not yet fully prepared to handle gRPC.

It has a couple of advantages over REST, like:

  • Type safety.

    • gRPC enforces message structures defined in Protocol Buffers. This ensures compatibility between services and prevents unexpected data types from causing errors.

  • Performance otimizations.

    • Uses a compact binary encoding format for messages, leading to faster transmissions and lower resource consumption compred to other JSON-based APIs.

  • Cleaner developement experience.

    • It offers features like streaming RPCs, allowing for efficient handling of data transfers or real-time updates.

gRPC can communicate over HTTP/2. This means it:

  • Supports traffic in binary.

  • Supports bi-directional communication. (Between Client-Backend)

gRPC has official support in:

  • GO

  • JAVA

  • C

    • Through C you can use:

      • C++

      • Python

      • Ruby

      • PHP

      • C#

      • Node.js

      • Dart

RPC (Remote Procedure Call)

A Client calls the Server, with a request, invoking a procedure and the Server responds with a response.

Communication Types

Unary

Client makes a single request and the Server responds with a single response.

Server Streaming

Client makes a single request and the Server responds one or multiple responses.

This helps the Client to use the data as it comes (piece by piece), and not have to wait the server to fully process and returns the hole data.

Client Streaming

Client makes multiple requests and the Server responds with a single response.

Like if you will upload a file, you may upload it in peaces. After the Server receives them all it process it and respond.

Bi Directional Streaming

Client makes multiple requests and the Server responds with multiple responses.

REST vs gRPC

REST

  • Text / Json

  • One-directional only

  • Higher latency

  • No contracts (higher change of error)

    • Like number as string.

  • No streaming support.

gRPC

  • Protocol Buffers

  • Bi-directional and Asyncronous

  • Lower lantency

  • Defined contract (.proto)

  • Streaming support.

Supported Languages
gRPCgRPC
Logo
Drawing
Drawing
Drawing
Drawing