Microservices with .NET
Microservices decompose applications into independently deployable services. .NET supports three communication patterns: REST (HTTP), gRPC (binary, high-performance), and message queues (async, decoupled via RabbitMQ/Azure Service Bus with MassTransit).
45 min•By Priygop Team•Last updated: Feb 2026
Communication Patterns
- REST — JSON over HTTP. Synchronous. Best for: client-facing APIs, simple service-to-service. Drawback: tight coupling, cascading failures
- gRPC — Binary Protocol Buffers over HTTP/2. 5-10x faster than REST. Best for: internal service communication with typed contracts
- Message Queues — Async decoupled messaging. RabbitMQ or Azure Service Bus with MassTransit. No direct dependency between services
- Saga pattern — Distributed transactions without 2PC. Choreography (events) or Orchestration (central coordinator)
- API Gateway — Single entry point (Ocelot, YARP). Route to services, authentication, rate limiting, load balancing
- Service discovery — Services register with Consul. Gateway discovers instances dynamically. Handles health checks
- Circuit breaker — Polly library. After N failures, open circuit (fail fast). Try again after timeout. Prevents cascade failures
- Outbox pattern — Save message to DB in same transaction as entity. Background process publishes. Guarantees at-least-once delivery