gRPC in .NET: Basics & More • Poornima Nayar • GOTO 2024

Learn gRPC essentials for modern .NET development: communication patterns, Protocol Buffers, code generation, versioning, and deployment best practices on Azure.

Key takeaways
  • gRPC is a high-performance, open-source RPC (Remote Procedure Call) framework designed for HTTP/2 and modern service-to-service communication

  • Protocol Buffers (protobuf) serve as gRPC’s data serialization format and contract definition language - they are language-neutral and platform-independent

  • Four main communication modes supported:

    • Unary (traditional request/response)
    • Server streaming
    • Client streaming
    • Bidirectional streaming
  • Code generation is key part of gRPC workflow:

    • Proto files define the contract
    • Tools generate server/client code for specific languages
    • Generated code handles serialization/deserialization
  • Built-in versioning support through:

    • Package naming
    • Field numbering
    • Backward/forward compatibility features
    • Non-breaking vs breaking changes clearly defined
  • Best suited for:

    • Microservices communication
    • Polyglot environments
    • High-performance requirements
    • Streaming scenarios
    • IoT and device communication
  • Requires careful consideration around:

    • Field numbering (impacts wire format)
    • Breaking vs non-breaking changes
    • Versioning strategy
    • Message design and evolution
  • Native support in .NET Core 3.0+ with full ASP.NET Core integration including:

    • Dependency injection
    • Authentication/authorization
    • Logging
    • Middleware
  • gRPC channels should be reused as they are expensive to create and maintain long-lived HTTP/2 connections

  • Hosting options on Azure include:

    • Container Apps
    • Linux App Service
    • Kubernetes Service