Professional Documents
Culture Documents
Memi Lavi
www.memilavi.com
gRPC
• Quite unique
• During the years it was found that there are three major
Performance
Request-Response Only
Limited Syntax
Performance
Large packets
Parsing
Request-Response pattern
Request: Response:
/api/v1/orders/17 {“orde_date”:”2022-07-
10”,...}
REST API
Service
Request-Response Only
Request: Response:
/api/v1/orders/17 {“orde_date”:”2022-07-
10”,...}
REST API
Service
Request-Response Only
Notification:
{“push_date”:”2022-07-
10”,...}
Service
Request-Response Only
• Polling
• Complex
Service
Limited Syntax
Read (=>GET)
Update (=>PUT)
Delete (=>DELETE)
Limited Syntax
• Examples:
• GET /api/v1/orders/17
• DELETE /api/v1/employee/84
• POST /api/v1/telemetry
• GET /api/v1/flights?from=LHR&to=JFK&date=2022-08-05
Limited Syntax
• Examples:
• Perform login
• Disable a device
History of gRPC
• Called Stubby
• Main principles:
• Performant
• Allows streaming
gRPC Basics
• gRPC is:
Web API
Based on HTTP/2
RPC Style
Web API
The Internet
Web
.NET HTTP API Python
Based on HTTP/2
• HTTP/1.1 was released in 1997
request/response model
Based on HTTP/2
• HTTP/2 is:
Based on HTTP/2
HTTP/1.1 HTTP/2
Based on HTTP/2
• Note:
from browsers
RPC Style
• gRPC name has two parts:
• g for Google
• RPC
RPC
GetWeather(“NYC”)
Client Server
38 GetWeather()
RPC
• Refresher
GetWeather(“NYC”)
GET /api/v1/weather?city=NYC
We have no idea
Client Server
what’s the
38 GetWeather() method name on
the server
Communication Styles
Client Streaming
Server Streaming
Bi-directional
Communication Styles
Unary
GetWeather(“NYC”)
Client Server
38 GetWeather()
Communication Styles
Client Streaming
• The client opens a connection to the server
• Sends continuous messages to the server
• Great for telemetry, chats, etc.
StoreTelemetry(“15”)
StoreTelemetry(“18”)
Client Server
StoreTelemetry()
Communication Styles
Server Streaming
• The client opens a connection to the server
• The server sends continuous messages using the connection
• Great for notifications, chat, etc.
And
And London?
What’s the forecast for NYC?
Rome?
Client 25
38 degrees
28 Server
Protobuf
happen
• A binary format
• Deadline = A fixed point in time until which the client will wait
• Language dependent