SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...AboutYouGmbH
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideTim Burks
 
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 gRPCShiju Varghese
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPCPrakash Divy
 
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 your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC ServiceJessie Barnett
 
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
 
What is gRPC introduction gRPC Explained
What is gRPC introduction gRPC ExplainedWhat is gRPC introduction gRPC Explained
What is gRPC introduction gRPC Explainedjeetendra mandal
 
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 SquareApigee | Google Cloud
 
Prometheus Overview
Prometheus OverviewPrometheus Overview
Prometheus OverviewBrian Brazil
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx InternalsJoshua Zhu
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersSATOSHI TAGOMORI
 
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventuremylittleadventure
 

Mais procurados (20)

Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 
gRPC
gRPC gRPC
gRPC
 
Power-up services with gRPC
Power-up services with gRPCPower-up services with gRPC
Power-up services with gRPC
 
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
 
gRPC with java
gRPC with javagRPC with java
gRPC with java
 
gRPC
gRPCgRPC
gRPC
 
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
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPC
 
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...
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
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!
 
What is gRPC introduction gRPC Explained
What is gRPC introduction gRPC ExplainedWhat is gRPC introduction gRPC Explained
What is gRPC introduction gRPC Explained
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
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
 
Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Prometheus Overview
Prometheus OverviewPrometheus Overview
Prometheus Overview
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx Internals
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventure
 

Semelhante a 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.docxAkhilMS30
 
CN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdfCN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdfAsifSalim12
 
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 stackRed Hat
 
gRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer ProtocolgRPC - Fastest Data Transfer Protocol
gRPC - Fastest Data Transfer ProtocolSougata 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 layerPranith Karampuri
 
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, GoogleAmbassador Labs
 
Building API Using GRPC And Scala
Building API Using GRPC And ScalaBuilding API Using GRPC And Scala
Building API Using GRPC And ScalaKnoldus Inc.
 
Towards constrained semantic web
Towards constrained semantic webTowards constrained semantic web
Towards constrained semantic web☕ Remy Rojas
 
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.pdfMahtabAhmedQureshi
 
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 ExpertAbhishek Sagar
 
Network protocols
Network protocolsNetwork protocols
Network protocolsAbiud Orina
 

Semelhante a 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
 

Último

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

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