Marcin Jahn | Dev Notebook
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • Home
  • Programming
  • Technologies
  • Projects
  • About
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips
  • An icon of the Networking section Networking
    • HTTP Protocol
    • OSI Model
    • TCP Procol
    • UDP Protocol
    • WebSocket
    • HSTS
    • DNS
    • Server Name Indication
    • gRPC
  • An icon of the Security section Security
    • OAuth2
      • Sender Constraint
    • Cryptography
      • Cryptography Basics
    • TPM
      • Overiew
      • TPM Entities
      • TPM Operations
  • An icon of the Linux section Linux
    • Gist of Linux Tooling
    • Unknown
    • SELinux
    • Containers
    • Bash Scripting
    • Linux From Scratch
    • Networking
  • An icon of the Kubernetes section Kubernetes
    • Meaning and Purpose
    • Cluster
    • Dev Environment
    • Kubernetes API
    • Objects
    • Pods
    • Scaling
    • Events
    • Storage
    • Configuration
    • Organizing Objects
    • Services
    • Ingress
    • Helm
  • An icon of the Observability section Observability
    • Tracing
  • An icon of the Databases section Databases
    • ACID
    • Glossary
    • Index
    • B-Tree and B+Tree
    • Partitioning and Sharding
    • Concurrency
    • Database Tips
  • An icon of the SQL Server section SQL Server
    • Overview
    • T-SQL
  • An icon of the MongoDB section MongoDB
    • NoSQL Overview
    • MongoDB Overview
    • CRUD
    • Free Text Search
  • An icon of the Elasticsearch section Elasticsearch
    • Overview
  • An icon of the Git section Git
    • Git
  • An icon of the Ansible section Ansible
    • Ansible
  • An icon of the Azure section Azure
    • Table Storage
    • Microsoft Identity
  • An icon of the Google Cloud section Google Cloud
    • Overview
  • An icon of the Blockchain section Blockchain
    • Overview
    • Smart Contracts
    • Solidity
    • Dapps
  • Home Assistant
    • Home Assistant Tips

gRPC

gRPC - GRPC Remote Procedure Call. The “G” could also just stand for “Google” which is one of the main drive forces behind the protocol. It’s a high performance, open-source universal RPC framework. gRPC uses Protocol Buffers v3.

Highlights

  • high serialization/deserialization performance (especially deserialization when compared to JSON)
  • wide adoption in programming languages
  • binary communication (no JSON, XML, whatever) - small size
  • contract-based
  • requires HTTP/2 (HTTPS by default)
  • uni- and bi-directional streaming
  • great for low-power devices (IoT)

Usage

  • backend-to-backend communication, e.g. between microservices

Usage on the frontend is not as straightforward as with REST.

Contracts

The Server and the Client are generated using the ProtoBuf.

ProtoBuf

Protocol Buffers (ProtoBuf) is a language for defining interfaces.

  • language/platform neutral
  • extensible
  • serializable
  • not specific to gRPC

It comes with its own set of types for defining data.

Example

Request:

1: 100
2: "Hello There"

Response:

1: 94.5
2: 15.4
3: .5

Streaming

Thanks to HTTP/2 base, gRPC supports streaming. It’s very similar to how websockets work. The streaming works in any direction (client -> server or server -> client), it can also be both ways at the same time.

To support streaming, the protobuf file needs to explicitly contain such information attached to the input of the chosen rpc.

Usage

.NET

Read here.

gRPC-Web

gRPC-Web is the way to call gRPC servers from the frontend layer (from JS). ASP.NET Core supports it via an additional NuGet package.

Tools

  • BloomRPC- “Postman” for gRPC

References

  • Pluralsight
  • A nice intro to protobuf
←  Server Name Indication
© 2023 Marcin Jahn | Dev Notebook | All Rights Reserved. | Built with Astro.