@stevejgordon
www.stevejgordon.co.uk
SERVICE B (NODE) SERVICE C (.NET)
SERVER
SERVICE A (.NET)
SERVER
CLIENT
SERVICE D (GO)
SERVER
CLIENT
CLIENT
PROTO A
PROTO A
PROTO B
PROTO B
PROTO C
PROTO C
Slide 23
Slide 23 text
@stevejgordon
www.stevejgordon.co.uk
• Unary
Single request with a single response – A normal function call
• Server Streaming
Single request with a stream of responses for the client to consume
• Client Streaming
Client sends a stream of requests, each receiving a single response
• Bidirectional Streaming
Client sends a stream of requests and consumes a stream of responses
Slide 24
Slide 24 text
STREAMING DEMOS
Slide 25
Slide 25 text
PERFORMANCE
Slide 26
Slide 26 text
REST Body
10,072 Bytes
GRPC Body
1,916 Bytes
RESULTS
80.98% SMALLER
Slide 27
Slide 27 text
@stevejgordon
www.stevejgordon.co.uk
• No need for *.proto
• Apply attributes to .NET interfaces and classes
• Interface(s) define your services
• Classes define your message models
• Can also use a *.proto to generate the C# code
• Share contracts as libraries between .NET servers and clients
Slide 28
Slide 28 text
CODE-FIRST gRPC DEMO
Slide 29
Slide 29 text
THE BIG FINISH DEMO!
Slide 30
Slide 30 text
@stevejgordon
www.stevejgordon.co.uk
ASP.NET Core
Service (.NET)
CLIENT
weather.proto
gRPC Weather
Service (.NET)
SERVER
weather.proto
HTTP
SignalR
HTTP gRPC
…
Slide 31
Slide 31 text
@stevejgordon
www.stevejgordon.co.uk
• Performance
• Efficient binary serialisation (low CPU overhead) using Protobuf
• Smaller payloads
• HTTP/2 is fundamentally quicker
• Code-gen server and clients for many languages/frameworks
• Contract based
• Supports first class streaming
Slide 32
Slide 32 text
@stevejgordon
www.stevejgordon.co.uk
• Code generation in .NET is C# only
• Kestrel doesn't support HTTP/2 with TLS on macOS
https://docs.microsoft.com/en-us/aspnet/core/grpc/aspnetcore?view=aspnetcore-3.0&tabs=visual-studio#grpc-and-aspnet-core-on-macos
• Harder to exercise without tools such as Postman
Slide 33
Slide 33 text
@stevejgordon
www.stevejgordon.co.uk
• A great choice for microservice communication
• A good way to support server-to-server communication in
polyglot environments
• Easy to get started using the gRPC service template
• gRPC .NET libraries make creating servers and clients very easy
https://github.com/grpc/grpc-dotnet
Slide 34
Slide 34 text
THANK YOU
@stevejgordon
www.stevejgordon.co.uk
https://app.pluralsight.com/profile/author/steve-gordon
http://bit.ly/dotnet-grpc