SlideShare a Scribd company logo
1 of 14
gRPC is…
• Popular open source RPC framework
• Largest RPC mindshare
• Cloud Native Computing Foundation project
• gRPC stands for gRPC Remote Procedure Calls
• Built with modern technologies
• HTTP/2
• Protocol Buffers
• Designed for modern apps
• High performance
• Platform independent
+ =
Protobuf (aka Protocol Buffers)
• IDL (interface definition language)
Describe once and generate interfaces for
any language
• Service model
Service method and structure of the
request and the response
• Wire format
Binary format for network transmission
syntax = "proto3";
message SubscribeRequest {
string topic = 1;
}
message Event {
int32 id = 1;
string details = 2;
}
service Topics {
rpc Subscribe(SubscribeRequest)
returns (stream Event);
}
5052 4920 2a20 4854 5450 2f32
0d0a 534d 0d0a 0d0a 0000 0004
0000 0000 0401 0000 0000 0000
Remote Procedure Calls vs HTTP APIs
• Contract first (proto file) • Content first (URLs, HTTP method, JSON)
• Contract is designed for humans
• Hides remoting complexity
• Content is designed for humans
• Emphasises HTTP
HTTP APIsRemote Procedure Calls
Performance
Developer productivity
Widest audience
Ease of getting started
Demo!
• Create gRPC service using template
• Create gRPC client
• Call service
Grpc.Core
Going deeper: gRPC on .NET Core
Grpc.Core
Grpc.Core.Api
Grpc.AspNetCore Grpc.Net.Client
• HTTP/2 via Kestrel
• Integrates with ASP.NET
• HTTP/2 via HttpClient
• DelegatingHandler
Key features - Performance
• Low network usage
• HTTP/2 binary framing and header compression
• Protobuf message serialization
0
100
200
300
400
500
600
700
800
1 2 10 20
Size(bytes)
Serialized items
JSON vs Protobuf Size Comparison
JSON
Protobuf
syntax = "proto3";
package sample;
message Test {
string query = 1;
int32 page_number = 2;
int32 result_per_page = 3;
repeated Ticker tickers = 4;
}
message Ticker {
string name = 1;
float value = 2;
}
{
"query": "myQuery",
"page_number": 42,
"result_per_page": 100,
"tickers": [
{
"name": "rPs",
"value": 9.768923
},
{
"name": "WEo",
"value": 6.067048
}
]
}
https://nilsmagnus.github.io/post/proto-json-sizes/
5052 4920 2a20 4854 5450 2f32
0d0a 534d 0d0a 0d0a 0000 0004
0000 0000 0401 0000 0000 0000
Key features - Performance
• HTTP/2 multiplexing
• Multiple calls via a TCP connection
• Avoid head-of-line blocking*
public abstract partial class TopicsBase
{
public virtual Task Subscribe(
SubscribeRequest request,
IServerStreamWriter<Event> responseStream,
ServerCallContext context)
{
throw new RpcException(new Status(StatusCode.Unimplemented, ""));
}
}
public partial class TopicsClient : ClientBase<TopicsClient>
{
public TopicsClient(ChannelBase channel) : base(channel)
{
}
public virtual AsyncServerStreamingCall<Event> Subscribe(
SubscribeRequest request,
CallOptions options)
{
return CallInvoker.AsyncServerStreamingCall(__Subscribe, options, request);
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="Topics.proto" GrpcServices="Server" />
<PackageReference Include="Grpc.AspNetCore" Version="2.29" />
</ItemGroup>
</Project>
Key features - Code generation
• All gRPC libraries have first-class code generation support
syntax = "proto3";
message SubscribeRequest {
string topic = 1;
}
message Event {
string details = 1;
}
service Topics {
rpc Subscribe(SubscribeRequest)
returns (stream Event);
} References Grpc.Tools
MSBuild integration for gRPC code generation
Registers *.proto file with the project
Key features - Multiple languages
Key features - Streaming
• gRPC uses HTTP/2 to enable streaming
gRPC-Web + Blazor Demo
• Add gRPC-Web on the server
• Call gRPC service from Blazor WebAssembly
gRPC for .NET 5
• gRPC-Web
• HttpSys support
• Keep alive
• Inter-process communication
• Performance
• HPack header compression
• Server allocations decreased by 75%
• Server RPS increased by 25%
• Client RPS increased by 300% (!!!)
• Span<T> support in Protobuf serializer
Try gRPC on .NET Core today!
• gRPC docs – https://docs.microsoft.com/aspnet/core/grpc
• gRPC with ASP.NET Core authentication
• Logging and diagnostics
• HttpClientFactory integration
• gRPC for WCF Developers
https://docs.microsoft.com/dotnet/architecture
Done! Questions?

More Related Content

What's hot

Getting Started with MongoDB Using the Microsoft Stack
Getting Started with MongoDB Using the Microsoft Stack Getting Started with MongoDB Using the Microsoft Stack
Getting Started with MongoDB Using the Microsoft Stack
MongoDB
 

What's hot (20)

Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
Webinar: Compliance and Data Protection in the Big Data Age: MongoDB Security...
Webinar: Compliance and Data Protection in the Big Data Age: MongoDB Security...Webinar: Compliance and Data Protection in the Big Data Age: MongoDB Security...
Webinar: Compliance and Data Protection in the Big Data Age: MongoDB Security...
 
GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016
 
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
 
Webinar: Schema Patterns and Your Storage Engine
Webinar: Schema Patterns and Your Storage EngineWebinar: Schema Patterns and Your Storage Engine
Webinar: Schema Patterns and Your Storage Engine
 
MongoDB and Spark
MongoDB and SparkMongoDB and Spark
MongoDB and Spark
 
Scaling your logging infrastructure using syslog-ng
Scaling your logging infrastructure using syslog-ngScaling your logging infrastructure using syslog-ng
Scaling your logging infrastructure using syslog-ng
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
 
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
 
gRPC
gRPCgRPC
gRPC
 
Getting Started with MongoDB Using the Microsoft Stack
Getting Started with MongoDB Using the Microsoft Stack Getting Started with MongoDB Using the Microsoft Stack
Getting Started with MongoDB Using the Microsoft Stack
 
An Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformAn Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media Platform
 
Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
 
Transitioning from SQL to MongoDB
Transitioning from SQL to MongoDBTransitioning from SQL to MongoDB
Transitioning from SQL to MongoDB
 
MongoDB World 2019: Finding the Right MongoDB Atlas Cluster Size: Does This I...
MongoDB World 2019: Finding the Right MongoDB Atlas Cluster Size: Does This I...MongoDB World 2019: Finding the Right MongoDB Atlas Cluster Size: Does This I...
MongoDB World 2019: Finding the Right MongoDB Atlas Cluster Size: Does This I...
 
MongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - SingaporeMongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - Singapore
 

Similar to gRPC on .NET Core - NDC Oslo 2020

Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 

Similar to gRPC on .NET Core - NDC Oslo 2020 (20)

ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep Dive
 
What you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyondWhat you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyond
 
.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and Tomorrow
 
DEVNET-2005 Using the Cisco Open SDN Controller RESTCONF APIs
DEVNET-2005	Using the Cisco Open SDN Controller RESTCONF APIsDEVNET-2005	Using the Cisco Open SDN Controller RESTCONF APIs
DEVNET-2005 Using the Cisco Open SDN Controller RESTCONF APIs
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
6 app-tcp
6 app-tcp6 app-tcp
6 app-tcp
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep dive
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twisted
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
Skydive 5/07/2016
Skydive 5/07/2016Skydive 5/07/2016
Skydive 5/07/2016
 
HTTP protocol and Streams Security
HTTP protocol and Streams SecurityHTTP protocol and Streams Security
HTTP protocol and Streams Security
 
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
Cotopaxi - IoT testing toolkit (Black Hat Asia 2019 Arsenal)
 
Adding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded SystemAdding Support for Networking and Web Technologies to an Embedded System
Adding Support for Networking and Web Technologies to an Embedded System
 
Harmonia open iris_basic_v0.1
Harmonia open iris_basic_v0.1Harmonia open iris_basic_v0.1
Harmonia open iris_basic_v0.1
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
 
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java PlatformMicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
 
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
 
KrakenD API Gateway
KrakenD API GatewayKrakenD API Gateway
KrakenD API Gateway
 
The Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics DevelopmentThe Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics Development
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
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 New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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...
 
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...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

gRPC on .NET Core - NDC Oslo 2020

  • 1.
  • 2. gRPC is… • Popular open source RPC framework • Largest RPC mindshare • Cloud Native Computing Foundation project • gRPC stands for gRPC Remote Procedure Calls • Built with modern technologies • HTTP/2 • Protocol Buffers • Designed for modern apps • High performance • Platform independent + =
  • 3. Protobuf (aka Protocol Buffers) • IDL (interface definition language) Describe once and generate interfaces for any language • Service model Service method and structure of the request and the response • Wire format Binary format for network transmission syntax = "proto3"; message SubscribeRequest { string topic = 1; } message Event { int32 id = 1; string details = 2; } service Topics { rpc Subscribe(SubscribeRequest) returns (stream Event); } 5052 4920 2a20 4854 5450 2f32 0d0a 534d 0d0a 0d0a 0000 0004 0000 0000 0401 0000 0000 0000
  • 4. Remote Procedure Calls vs HTTP APIs • Contract first (proto file) • Content first (URLs, HTTP method, JSON) • Contract is designed for humans • Hides remoting complexity • Content is designed for humans • Emphasises HTTP HTTP APIsRemote Procedure Calls Performance Developer productivity Widest audience Ease of getting started
  • 5. Demo! • Create gRPC service using template • Create gRPC client • Call service
  • 6. Grpc.Core Going deeper: gRPC on .NET Core Grpc.Core Grpc.Core.Api Grpc.AspNetCore Grpc.Net.Client • HTTP/2 via Kestrel • Integrates with ASP.NET • HTTP/2 via HttpClient • DelegatingHandler
  • 7. Key features - Performance • Low network usage • HTTP/2 binary framing and header compression • Protobuf message serialization 0 100 200 300 400 500 600 700 800 1 2 10 20 Size(bytes) Serialized items JSON vs Protobuf Size Comparison JSON Protobuf syntax = "proto3"; package sample; message Test { string query = 1; int32 page_number = 2; int32 result_per_page = 3; repeated Ticker tickers = 4; } message Ticker { string name = 1; float value = 2; } { "query": "myQuery", "page_number": 42, "result_per_page": 100, "tickers": [ { "name": "rPs", "value": 9.768923 }, { "name": "WEo", "value": 6.067048 } ] } https://nilsmagnus.github.io/post/proto-json-sizes/ 5052 4920 2a20 4854 5450 2f32 0d0a 534d 0d0a 0d0a 0000 0004 0000 0000 0401 0000 0000 0000
  • 8. Key features - Performance • HTTP/2 multiplexing • Multiple calls via a TCP connection • Avoid head-of-line blocking*
  • 9. public abstract partial class TopicsBase { public virtual Task Subscribe( SubscribeRequest request, IServerStreamWriter<Event> responseStream, ServerCallContext context) { throw new RpcException(new Status(StatusCode.Unimplemented, "")); } } public partial class TopicsClient : ClientBase<TopicsClient> { public TopicsClient(ChannelBase channel) : base(channel) { } public virtual AsyncServerStreamingCall<Event> Subscribe( SubscribeRequest request, CallOptions options) { return CallInvoker.AsyncServerStreamingCall(__Subscribe, options, request); } } <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <Protobuf Include="Topics.proto" GrpcServices="Server" /> <PackageReference Include="Grpc.AspNetCore" Version="2.29" /> </ItemGroup> </Project> Key features - Code generation • All gRPC libraries have first-class code generation support syntax = "proto3"; message SubscribeRequest { string topic = 1; } message Event { string details = 1; } service Topics { rpc Subscribe(SubscribeRequest) returns (stream Event); } References Grpc.Tools MSBuild integration for gRPC code generation Registers *.proto file with the project
  • 10. Key features - Multiple languages
  • 11. Key features - Streaming • gRPC uses HTTP/2 to enable streaming
  • 12. gRPC-Web + Blazor Demo • Add gRPC-Web on the server • Call gRPC service from Blazor WebAssembly
  • 13. gRPC for .NET 5 • gRPC-Web • HttpSys support • Keep alive • Inter-process communication • Performance • HPack header compression • Server allocations decreased by 75% • Server RPS increased by 25% • Client RPS increased by 300% (!!!) • Span<T> support in Protobuf serializer
  • 14. Try gRPC on .NET Core today! • gRPC docs – https://docs.microsoft.com/aspnet/core/grpc • gRPC with ASP.NET Core authentication • Logging and diagnostics • HttpClientFactory integration • gRPC for WCF Developers https://docs.microsoft.com/dotnet/architecture Done! Questions?

Editor's Notes

  1. -Me -Developer on ASP.NET team -Working on gRPC since beginning of the year -Launched last month with 3.0
  2. -There are alternative RPC frameworks, e.g. Thrift -Developer community is unifying behind gRPC -gRPC is run by CNCF. Microsoft contributing to CNCF -Does not stand for Google RPC -gRPC is not new, open sourced in 2015 -Union of two technologies, HTTP2 and Protocol Buffers -Designed for modern apps, particularly microservices
  3. Protocol Buffers serves three purposes: -Language independent definition of Protobuf messages. Written in proto file that can be shared between apps -Definition of services for use on server and client -Binary format of messages. Small and fast, but not human readable
  4. gRPC is an opination contract-first RPC framework HTTP APIs focus on the shape and content of HTTP (contract optional) proto files are designed for humans to write and read. Content is binary HTTP APIs are the opposite: content is human readable. Optional schema is rather verbose gRPC methods are designed to hide complexity of remoting Call them like you would a method, no creating HTTP messages or JSON content
  5. Create gRPC project in VS Talk through proto – messages, service, this is the contract Talk through service – generated file, F12, location, ILogger (DI) Launch. Browse to server Create client project – add packages, add proto Look at service references Update Program.cs
  6. Lets go a bit deeper into what has been added in .NET Core Grpc.Core is the existing C# gRPC stack. First released 2015 .NET wrapper of a native implementation of gRPC and http2 Slow, large native dependencies New: Grpc.AspNetCore and Grpc.Net.Client - GrpcAspNetCore: uses Kestrel’s HTTP/2 support, integrates with ASP.NET - The new client uses HttpClient internally. Can use Delegating Handler outgoing middleware One of our goals has been portablity between Grpc.Core and grpc on .net core Split common API into its own package and reuse End result: existing gRPC services can use newer server and client Grpc.Core is not going away. Has features that new bits don’t, supports .NET Framework
  7. A key benefit of gRPC vs REST is small size of requests -HTTP/2 is binary compared to text based HTTP1 -HTTP/2 supports header compression. Commonly occurring headers, e.g. content-type, are compressed to a few bits per request -Protobuf is significantly smaller than JSON JSON is a self describing format – characters are included to differentiate objects/arrays/strings/numbers Protobuf requires the proto file to make sense of content Simple comparison between JSON and Protobuf Protobuf is 30% the size of JSON Difference reduces to 50% with gzip
  8. HTTP/2 multiplexing makes more efficient use of TCP connections Multiplexing improves on HTTP1.1 pipelining -Pipelining requires the order of requests and responses match -A large image or slow API call may prevent faster requests from completing HTTP/3 should improve this situation even more.
  9. Code generation is at the core of gRPC Code generation is driving by Protocol Buffer IDL Example -Simple server streaming call -csproj references proto file in ProtoBuf item -Grpc.Tools has targets to generate .NET types at design time -Server is a base type that requires implementation -Client is strongly typed, created with channel that specifies the server location Proto files can be shared between servers, and languages.
  10. gRPC is supported in every language -Common set of interop tests -gRPC on .NET Core is continuously tested against other implementations
  11. HTTP/2 has excellent streaming support gRPC uses HTTP/2 streaming to enable message streaming Unary. Like REST. Single request, single reply Server streaming is initiated with a request, returns a stream of responses. Example, subscribing to updates. Client streaming is the opposite: stream requests, finish with response. Example: uploading data Bi directional stream is streaming in both direction. Example: chat room gRPC streaming is a really easy way to create realtime services.
  12. I’m going to demo gRPC in the browser. gRPC traditionally can’t run in the browser but this feature makes it very simple in .NET Run project. Demo weather page Look at REST request. Note size Enable gRPC-Web on the server Package ref UseGrpcWeb Call gRPC Update csproj Update Program.cs Inject channel Update call code Add ToDateTime Run project. Note new size
  13. gRPC-Web. Available now HttpSys is a server that is part of Windows. Supported in 5.0, although it will require you to run on a Windows version that includes an updated HttpSys Keep alive pings help keep connections alive when they are in use, and close them when one side doesn’t respond Keep long lived, inactive streams alive Better first request performance by keeping the connection open Inter-process communication is gRPC calls between apps on the same machine. Can be done today using TCP sockets, but we want to support named pipes and unix domain sockets A big focus is performance. Graph shows requests per second with different gRPC servers. The jump in the .NET Core results in this graph is from moving from .NET 3.1 to .NET 5 Added Hpacker header compression to Kestrel. Commonly reaccuring headers are compressed to a fraction of there size Pool and reuse HTTP/2 streams in Kestrel, reducing allocations by 75% Increased HTTP/2 server RPS by 25% Identified lock contention in the client, increasing RPS by 300%! Finally, we’re working with the Protobuf project to support Span<T> in their serializer
  14. gRPC for .NET Core is on NuGet today. A template ships with .NET Core 3.1 For more information, the best place to go is the docs. There is lots there that I haven’t discussed today We’ve worked with the community to write a book on moving WCF services to gRPC That’s it! Thank you for your time. Questions