SlideShare ist ein Scribd-Unternehmen logo
1 von 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?

Weitere ähnliche Inhalte

Was ist angesagt?

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...MongoDB
 
GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016GRPC 101 - DevFest Belgium 2016
GRPC 101 - DevFest Belgium 2016Alex Van Boxel
 
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 2017Mustafa AKIN
 
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 EngineMongoDB
 
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-ngPeter Czanik
 
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 ...MongoDB
 
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 AtlasMongoDB
 
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
 
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
 
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 PlatformMongoDB
 
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
 
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 StartMongoDB
 
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...MongoDB
 
Transitioning from SQL to MongoDB
Transitioning from SQL to MongoDBTransitioning from SQL to MongoDB
Transitioning from SQL to MongoDBMongoDB
 
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
 
MongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - SingaporeMongoDB Atlas Workshop - Singapore
MongoDB Atlas Workshop - SingaporeAshnikbiz
 

Was ist angesagt? (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
 

Ähnlich wie gRPC on .NET Core - NDC Oslo 2020

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 DiveJon Galloway
 
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 beyondJon Galloway
 
.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and TomorrowJon Galloway
 
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 APIsCisco DevNet
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveMadhu Venugopal
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twistedsdsern
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHPZoran Jeremic
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 
HTTP protocol and Streams Security
HTTP protocol and Streams SecurityHTTP protocol and Streams Security
HTTP protocol and Streams SecurityBlueinfy Solutions
 
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)Jakub Botwicz
 
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 SystemJohn Efstathiades
 
Harmonia open iris_basic_v0.1
Harmonia open iris_basic_v0.1Harmonia open iris_basic_v0.1
Harmonia open iris_basic_v0.1Yongyoon Shin
 
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...apidays
 
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 PlatformMike Croft
 
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}Md. Sadhan Sarker
 
The Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics DevelopmentThe Ongoing Democratization of Robotics Development
The Ongoing Democratization of Robotics Developmentukdpe
 

Ähnlich wie 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
 

Kürzlich hochgeladen

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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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 Processorsdebabhi2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

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...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

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?

Hinweis der Redaktion

  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