Skip to main content

gRPC: High-Performance Microservices with Protocol Buffers

Presentation guide on gRPC, Protocol Buffers, HTTP/2 multiplexing, and the Backend for Frontend (BFF) architectural pattern using Node.js and Python.

Team Members​

  • Fiber Piedrahita
  • Daniel Fajardo
  • Paula Ferreira

Slides and Resources​

gRPC-Pokedex
Project Links and Presentation

1. gRPC and Protocol Buffers Foundations​

gRPC (gRPC Remote Procedure Calls) is an open-source, high-performance RPC framework initially designed by Google. Unlike conventional REST architectures passing textual JSON payloads over HTTP/1.1, gRPC is anchored on two core technical pillars:

  1. Protocol Buffers (Protobuf): A language-neutral, platform-neutral, extensible mechanism for serializing structured binary data.
  2. HTTP/2 Transport: Supports full request multiplexing over a single persistent TCP connection, header compression (HPACK), and bi-directional streaming.
Clic para ampliar

2. Comparison: gRPC vs. REST​

CriteriagRPCTraditional REST
Transport ProtocolHTTP/2 (Multiplexed)Typically HTTP/1.1 or HTTP/2
Payload FormatBinary (Protocol Buffers)Textual (JSON or XML)
Contract DefinitionMandatory and strict (.proto)Optional (OpenAPI / Swagger)
PerformanceHigh throughput, minimal network serialization overheadModerate overhead from JSON text serialization
Streaming ModesUnary, Server Streaming, Client Streaming, BidirectionalPredominantly unary request/response
Primary Use CaseInter-service microservice backplanesPublic-facing web APIs consumed by browsers

3. Practical Demo: Pokédex with BFF Architecture​

1

Define Contract in Protocol Buffers

proto/pokemon.proto
syntax = "proto3";

package pokemon;

service PokemonService {
rpc GetPokemon (PokemonRequest) returns (PokemonResponse);
}

message PokemonRequest {
string name_or_id = 1;
}

message PokemonResponse {
int32 id = 1;
string name = 2;
int32 height = 3;
int32 weight = 4;
repeated string types = 5;
string sprite_url = 6;
string description = 7;
}
2

Implement gRPC Server in Node.js

The Node.js server compiles the .proto schema, queries the upstream PokeAPI, and responds to gRPC clients via structured binary streams:

cd backend_node
npm install
node server.js
3

Implement Python gRPC Client (Flask BFF)

The Python Backend for Frontend (BFF) consumes the gRPC service and serves HTML/JSON to the client browser:

Practical Demo: Pokédex with BFF
cd frontend_python
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py