Roadmap › Microservices & System Design with .NET › Module: Communication
Lessons in this course (9)

3. Synchronous communication — REST, gRPC and the API gateway

Intermediate★ Must knowLesson 3 of 9
REST (HTTP + JSON)gRPC (HTTP/2 + Protobuf)
ContractOpenAPI (optional).proto file (required, code-generated)
PayloadText JSON — readable, largerBinary — small and fast
StreamingLimited (SSE, WebSockets)Client, server and bidirectional streaming
Browser supportNativeNeeds gRPC-Web
Best forPublic APIs, browser clientsInternal service-to-service calls
csharp
// Typed HttpClient with built-in resilience (.NET 8+)
builder.Services.AddHttpClient<CatalogClient>(c => c.BaseAddress = new Uri("https+http://catalog"))
       .AddStandardResilienceHandler();   // retry, circuit breaker, timeouts

API gateway — single entry point for clients: routing, TLS termination, authentication, rate limiting, request aggregation, caching. In .NET: YARP; in Azure: API Management or Application Gateway. Backend-for-Frontend (BFF): a gateway per client type (web, mobile) shaped for that client.

json
// YARP appsettings.json
"ReverseProxy": {
  "Routes":   { "orders": { "ClusterId": "orders", "Match": { "Path": "/api/orders/{**rest}" } } },
  "Clusters": { "orders": { "Destinations": { "d1": { "Address": "http://orders-api:8080/" } } } }
}

Danger: long synchronous call chains (A → B → C → D) multiply latency and failure probability. Prefer async messaging for anything that doesn't need an immediate answer.