SlideShare a Scribd company logo
gRPC Design and Implementation
gRPC Team
@grpcio
Motivation for RPC systems
● Large-scale distributed systems actually composed of microservices
○ Allows loosely-coupled and even multilingual development
○ Scalability: things, cores, devices, nodes, clusters, and data centers (DCs)
● Communication predominantly structured as RPCs
○ Many models of RPC communication
○ Terminology: Client uses a stub to call a method running on a service/server
○ Easiest interfaces (synchronous, unary) resemble local procedure calls
translated to network activity by code generator and RPC library
○ High-performance interfaces (async, streaming) look like Active Messaging
● Long way from textbook description of RPCs!
@grpcio
Application composed of microservices
Data Store Task
Server
Computation Task
Server
Stub
UI Task
Stub
Monitoring Task
Server
Stub
@grpcio
gRPC: Motivation
● Google has had 4 generations of internal
RPC systems, called Stubby
○ All production applications and systems
built using RPCs
○ Over 1010
RPCs per second, fleetwide
○ APIs for C++, Java, Python, Go
○ Not suitable for open-source community!
(Tight coupling with internal tools)
● Apply scalability, performance, and API
lessons to external open-source
@grpcio
gRPC: Summary
● Multi-language, multi-platform framework
○ Native implementations in C, Java, and Go
○ C stack wrapped by C++, C#, Node, ObjC, Python, Ruby, PHP
○ Platforms supported: Linux, Android, iOS, MacOS, Windows
○ This talk: focus on C++ API and implementation (designed for performance)
● Transport over HTTP/2 + TLS
○ Leverage existing network protocols and infrastructure
○ Efficient use of TCP - 1 connection shared across concurrent framed streams
○ Native support for secure bidirectional streaming
● C/C++ implementation goals
○ High throughput and scalability, low latency
○ Minimal external dependencies
Using HTTP/2 as a transport
@grpcio
Using an HTTP transport: Why and How
● Network infrastructure well-designed to
support HTTP
○ Firewalls, load balancers, encryption,
authentication, compression, ...
● Basic idea: treat RPCs as references to
HTTP objects
○ Encode request method name as URI
○ Encode request parameters as content
○ Encode return value in HTTP response
@grpcio
● Request-Response protocol
○ Each connection supports pipelining
○ … but not parallelism (in-order only)
○ Need multiple connections per client-server
pair to avoid in-order stalls across multiple
requests → multiple CPU-intensive TLS
handshakes, higher memory footprint
● Content may be compressed
○ … but headers are text format
● Naturally supports single-direction streaming
○ … but not bidirectional
Using an HTTP/1.1 transport and its limitations
@grpcio
● One TCP connection for each
client-server pair
● Request → Stream
○ Streams are multiplexed
using framing
● Compact binary framing layer
○ Prioritization
○ Flow control
○ Server push
● Header compression
● Directly supports bidirectional
streaming
HTTP/2 in a Nutshell
HTTP/2HTTP/1.1
http://www.http2demo.io/
gRPC
@grpcio
● IDL to describe service API
● Automatically generates client
stubs and abstract server classes
in 10+ languages
● Takes advantage of feature set of
HTTP/2
gRPC in a nutshell
@grpcio
● Google’s Lingua Franca for
serializing data: RPCs and storage
● Binary data representation
● Structures can be extended and
maintain backward compatibility
● Code generators for many
languages
● Strongly typed
● Not required for gRPC, but very
handy
An Aside: Protocol Buffers syntax = “proto3”;
message Person {
string name = 1;
int32 id = 2;
string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
string number = 1;
PhoneType type = 2;
}
repeated PhoneNumber phone = 4;
}
@grpcio
Example gRPC client/server architecture
@grpcio
Getting Started
Define a service in a .proto file using
Protocol Buffers IDL
Generate server and client stub code using
the protocol buffer compiler
Extend the generated server class in your
language to fill in the logic of your service
Invoke it using the generated client stubs
@grpcio
service RouteGuide {
rpc GetFeature(Point) returns (Feature);
rpc RouteChat(stream RouteNote) returns (stream RouteNote);
}
Example Service Definition
message Point {
int32 Latitude = 1;
int32 Longitude = 2;
}
message RouteNote {
Point location = 1;
string message = 2;
}
message Feature {
string name = 1;
Point location = 2;
}
@grpcio
An (anonymized) case study
● Service needs to support bidirectional streaming with clients
● Attempt 1: Directly use TCP sockets
○ Functional in production data center, but not on Internet (firewalls, etc)
○ Programmer responsible for all network management and data transfer
● Attempt 2: JSON-based RPC over two HTTP/1.1 connections
○ Start two: one for request streaming and one for response streaming
○ But they might end up load-balanced to different back-end servers, so the
backing servers require shared state
○ Can only support 1 streaming RPC at a time for a client-server pair
● Attempt 3: gRPC
○ Natural fit
@grpcio
Authentication
SSL/TLS
gRPC has SSL/TLS integration and promotes the use of SSL/TLS to authenticate the
server, and encrypt all the data exchanged between the client and the server.
Optional mechanisms are available for clients to provide certificates to accomplish
mutual authentication.
OAuth 2.0
gRPC provides a generic mechanism to attach metadata to requests and responses.
Can be used to attach OAuth 2.0 Access Tokens to RPCs being made at a client.
Wrap-up
@grpcio
grpc is Open Source
We welcome your help!
http://grpc.io/contribute
https://github.com/grpc
irc.freenode.net #grpc
@grpcio
grpc-io@googlegroups.com
Occasional public meetups with free pizza

More Related Content

What's hot

Power-up services with gRPC
Power-up services with gRPCPower-up services with gRPC
Power-up services with gRPC
The Software House
 
gRPC
gRPCgRPC
GRPC.pptx
GRPC.pptxGRPC.pptx
GRPC.pptx
Afzal Juneja
 
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Codemotion
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
Sathiyaseelan Muthu kumar
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API's
Luram Archanjo
 
gRPC with java
gRPC with javagRPC with java
gRPC with java
Knoldus Inc.
 
What is gRPC introduction gRPC Explained
What is gRPC introduction gRPC ExplainedWhat is gRPC introduction gRPC Explained
What is gRPC introduction gRPC Explained
jeetendra mandal
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
Tim Burks
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
Jessie Barnett
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
Apigee | Google Cloud
 
Inter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPCInter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPC
Shiju Varghese
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Shiju Varghese
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
Alex Borysov
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
Kong Inc.
 
Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
Knoldus Inc.
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
Chetan Gadodia
 
Faster packet processing in Linux: XDP
Faster packet processing in Linux: XDPFaster packet processing in Linux: XDP
Faster packet processing in Linux: XDP
Daniel T. Lee
 

What's hot (20)

Power-up services with gRPC
Power-up services with gRPCPower-up services with gRPC
Power-up services with gRPC
 
gRPC
gRPCgRPC
gRPC
 
GRPC.pptx
GRPC.pptxGRPC.pptx
GRPC.pptx
 
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
Introduction to gRPC: A general RPC framework that puts mobile and HTTP/2 fir...
 
gRPC
gRPC gRPC
gRPC
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API's
 
gRPC with java
gRPC with javagRPC with java
gRPC with java
 
What is gRPC introduction gRPC Explained
What is gRPC introduction gRPC ExplainedWhat is gRPC introduction gRPC Explained
What is gRPC introduction gRPC Explained
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
 
Inter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPCInter-Process Communication in Microservices using gRPC
Inter-Process Communication in Microservices using gRPC
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
 
gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!gRPC vs REST: let the battle begin!
gRPC vs REST: let the battle begin!
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
 
Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Faster packet processing in Linux: XDP
Faster packet processing in Linux: XDPFaster packet processing in Linux: XDP
Faster packet processing in Linux: XDP
 

Similar to gRPC Design and Implementation

CN 6131(15) Module IV.docx
CN 6131(15) Module IV.docxCN 6131(15) Module IV.docx
CN 6131(15) Module IV.docx
AkhilMS30
 
CN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdfCN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdf
AsifSalim12
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
Red Hat
 
gRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer ProtocolgRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer Protocol
Sougata Pal
 
Gluster dev session #6 understanding gluster's network communication layer
Gluster dev session #6  understanding gluster's network   communication layerGluster dev session #6  understanding gluster's network   communication layer
Gluster dev session #6 understanding gluster's network communication layer
Pranith Karampuri
 
Transport Layer
Transport LayerTransport Layer
Transport Layer
Dr Shashikant Athawale
 
Cloud Native API Design and Management
Cloud Native API Design and ManagementCloud Native API Design and Management
Cloud Native API Design and Management
AllBits BVBA (freelancer)
 
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
Amazon Web Services
 
Nachos Theoretical assigment 3
Nachos Theoretical assigment 3Nachos Theoretical assigment 3
Nachos Theoretical assigment 3colli03
 
Article http over transport protocols
Article   http over transport protocolsArticle   http over transport protocols
Article http over transport protocolsIcaro Camelo
 
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleBringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Ambassador Labs
 
Building API Using GRPC And Scala
Building API Using GRPC And ScalaBuilding API Using GRPC And Scala
Building API Using GRPC And Scala
Knoldus Inc.
 
KrakenD API Gateway
KrakenD API GatewayKrakenD API Gateway
KrakenD API Gateway
Albert Lombarte
 
Towards constrained semantic web
Towards constrained semantic webTowards constrained semantic web
Towards constrained semantic web
☕ Remy Rojas
 
Go at uber
Go at uberGo at uber
Go at uber
Rob Skillington
 
Http/2
Http/2Http/2
LEC_10_Week_10_Server_Configuration_in_Linux.pdf
LEC_10_Week_10_Server_Configuration_in_Linux.pdfLEC_10_Week_10_Server_Configuration_in_Linux.pdf
LEC_10_Week_10_Server_Configuration_in_Linux.pdf
MahtabAhmedQureshi
 
Hyper Text Transfer Protocol
Hyper Text Transfer ProtocolHyper Text Transfer Protocol
Hyper Text Transfer Protocol
SouganthikaSankaresw
 
Master Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to ExpertMaster Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to Expert
Abhishek Sagar
 
Network protocols
Network protocolsNetwork protocols
Network protocols
Abiud Orina
 

Similar to gRPC Design and Implementation (20)

CN 6131(15) Module IV.docx
CN 6131(15) Module IV.docxCN 6131(15) Module IV.docx
CN 6131(15) Module IV.docx
 
CN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdfCN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdf
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
 
gRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer ProtocolgRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer Protocol
 
Gluster dev session #6 understanding gluster's network communication layer
Gluster dev session #6  understanding gluster's network   communication layerGluster dev session #6  understanding gluster's network   communication layer
Gluster dev session #6 understanding gluster's network communication layer
 
Transport Layer
Transport LayerTransport Layer
Transport Layer
 
Cloud Native API Design and Management
Cloud Native API Design and ManagementCloud Native API Design and Management
Cloud Native API Design and Management
 
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
How Netflix Uses Amazon Kinesis Streams to Monitor and Optimize Large-scale N...
 
Nachos Theoretical assigment 3
Nachos Theoretical assigment 3Nachos Theoretical assigment 3
Nachos Theoretical assigment 3
 
Article http over transport protocols
Article   http over transport protocolsArticle   http over transport protocols
Article http over transport protocols
 
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, GoogleBringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
Bringing Learnings from Googley Microservices with gRPC - Varun Talwar, Google
 
Building API Using GRPC And Scala
Building API Using GRPC And ScalaBuilding API Using GRPC And Scala
Building API Using GRPC And Scala
 
KrakenD API Gateway
KrakenD API GatewayKrakenD API Gateway
KrakenD API Gateway
 
Towards constrained semantic web
Towards constrained semantic webTowards constrained semantic web
Towards constrained semantic web
 
Go at uber
Go at uberGo at uber
Go at uber
 
Http/2
Http/2Http/2
Http/2
 
LEC_10_Week_10_Server_Configuration_in_Linux.pdf
LEC_10_Week_10_Server_Configuration_in_Linux.pdfLEC_10_Week_10_Server_Configuration_in_Linux.pdf
LEC_10_Week_10_Server_Configuration_in_Linux.pdf
 
Hyper Text Transfer Protocol
Hyper Text Transfer ProtocolHyper Text Transfer Protocol
Hyper Text Transfer Protocol
 
Master Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to ExpertMaster Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to Expert
 
Network protocols
Network protocolsNetwork protocols
Network protocols
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

gRPC Design and Implementation

  • 1. gRPC Design and Implementation gRPC Team
  • 2. @grpcio Motivation for RPC systems ● Large-scale distributed systems actually composed of microservices ○ Allows loosely-coupled and even multilingual development ○ Scalability: things, cores, devices, nodes, clusters, and data centers (DCs) ● Communication predominantly structured as RPCs ○ Many models of RPC communication ○ Terminology: Client uses a stub to call a method running on a service/server ○ Easiest interfaces (synchronous, unary) resemble local procedure calls translated to network activity by code generator and RPC library ○ High-performance interfaces (async, streaming) look like Active Messaging ● Long way from textbook description of RPCs!
  • 3. @grpcio Application composed of microservices Data Store Task Server Computation Task Server Stub UI Task Stub Monitoring Task Server Stub
  • 4. @grpcio gRPC: Motivation ● Google has had 4 generations of internal RPC systems, called Stubby ○ All production applications and systems built using RPCs ○ Over 1010 RPCs per second, fleetwide ○ APIs for C++, Java, Python, Go ○ Not suitable for open-source community! (Tight coupling with internal tools) ● Apply scalability, performance, and API lessons to external open-source
  • 5. @grpcio gRPC: Summary ● Multi-language, multi-platform framework ○ Native implementations in C, Java, and Go ○ C stack wrapped by C++, C#, Node, ObjC, Python, Ruby, PHP ○ Platforms supported: Linux, Android, iOS, MacOS, Windows ○ This talk: focus on C++ API and implementation (designed for performance) ● Transport over HTTP/2 + TLS ○ Leverage existing network protocols and infrastructure ○ Efficient use of TCP - 1 connection shared across concurrent framed streams ○ Native support for secure bidirectional streaming ● C/C++ implementation goals ○ High throughput and scalability, low latency ○ Minimal external dependencies
  • 6. Using HTTP/2 as a transport
  • 7. @grpcio Using an HTTP transport: Why and How ● Network infrastructure well-designed to support HTTP ○ Firewalls, load balancers, encryption, authentication, compression, ... ● Basic idea: treat RPCs as references to HTTP objects ○ Encode request method name as URI ○ Encode request parameters as content ○ Encode return value in HTTP response
  • 8. @grpcio ● Request-Response protocol ○ Each connection supports pipelining ○ … but not parallelism (in-order only) ○ Need multiple connections per client-server pair to avoid in-order stalls across multiple requests → multiple CPU-intensive TLS handshakes, higher memory footprint ● Content may be compressed ○ … but headers are text format ● Naturally supports single-direction streaming ○ … but not bidirectional Using an HTTP/1.1 transport and its limitations
  • 9. @grpcio ● One TCP connection for each client-server pair ● Request → Stream ○ Streams are multiplexed using framing ● Compact binary framing layer ○ Prioritization ○ Flow control ○ Server push ● Header compression ● Directly supports bidirectional streaming HTTP/2 in a Nutshell
  • 11. gRPC
  • 12. @grpcio ● IDL to describe service API ● Automatically generates client stubs and abstract server classes in 10+ languages ● Takes advantage of feature set of HTTP/2 gRPC in a nutshell
  • 13. @grpcio ● Google’s Lingua Franca for serializing data: RPCs and storage ● Binary data representation ● Structures can be extended and maintain backward compatibility ● Code generators for many languages ● Strongly typed ● Not required for gRPC, but very handy An Aside: Protocol Buffers syntax = “proto3”; message Person { string name = 1; int32 id = 2; string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { string number = 1; PhoneType type = 2; } repeated PhoneNumber phone = 4; }
  • 15. @grpcio Getting Started Define a service in a .proto file using Protocol Buffers IDL Generate server and client stub code using the protocol buffer compiler Extend the generated server class in your language to fill in the logic of your service Invoke it using the generated client stubs
  • 16. @grpcio service RouteGuide { rpc GetFeature(Point) returns (Feature); rpc RouteChat(stream RouteNote) returns (stream RouteNote); } Example Service Definition message Point { int32 Latitude = 1; int32 Longitude = 2; } message RouteNote { Point location = 1; string message = 2; } message Feature { string name = 1; Point location = 2; }
  • 17. @grpcio An (anonymized) case study ● Service needs to support bidirectional streaming with clients ● Attempt 1: Directly use TCP sockets ○ Functional in production data center, but not on Internet (firewalls, etc) ○ Programmer responsible for all network management and data transfer ● Attempt 2: JSON-based RPC over two HTTP/1.1 connections ○ Start two: one for request streaming and one for response streaming ○ But they might end up load-balanced to different back-end servers, so the backing servers require shared state ○ Can only support 1 streaming RPC at a time for a client-server pair ● Attempt 3: gRPC ○ Natural fit
  • 18. @grpcio Authentication SSL/TLS gRPC has SSL/TLS integration and promotes the use of SSL/TLS to authenticate the server, and encrypt all the data exchanged between the client and the server. Optional mechanisms are available for clients to provide certificates to accomplish mutual authentication. OAuth 2.0 gRPC provides a generic mechanism to attach metadata to requests and responses. Can be used to attach OAuth 2.0 Access Tokens to RPCs being made at a client.
  • 20. @grpcio grpc is Open Source We welcome your help! http://grpc.io/contribute https://github.com/grpc irc.freenode.net #grpc @grpcio grpc-io@googlegroups.com Occasional public meetups with free pizza