Choosing an API style: REST over HTTP, gRPC, GraphQL and asynchronous messaging compared on contracts, performance, client support, caching, coupling and failure semantics, with typical placements in a .NET 10 system on Azure.
REST is the default for public and partner APIs: universal client support, HTTP caching and simple tooling. gRPC suits internal service-to-service calls: protobuf contracts, HTTP/2, binary payloads and streaming, but weak browser support. GraphQL fits varied front ends that need different shapes of the same data, at the cost of HTTP caching, resolver N+1 problems and query cost limits. Asynchronous messaging (Azure Service Bus, Event Grid) is for decoupling in time: events, long-running work and load levelling, with at-least-once delivery and eventual consistency.
Most real systems mix them: REST or GraphQL at the edge, gRPC or REST between services, messaging for events. The trade-off is always coupling and simplicity vs efficiency and flexibility.
"I choose by who the client is and what kind of coupling I can accept. REST over HTTP and JSON is my default for anything public or partner-facing: every language and tool speaks it, it works through every proxy and CDN, GET responses can be cached, and OpenAPI gives us docs and SDKs. gRPC is what I reach for between internal services when calls are chatty or latency-sensitive: the protobuf contract generates strongly typed clients in .NET, payloads are compact, HTTP/2 multiplexes calls, and it supports streaming and deadlines natively. The catch is browsers, which need gRPC-Web or JSON transcoding, and load balancers that must understand HTTP/2.
GraphQL solves a different problem: many front ends that each want a different shape of data. The client asks for exactly the fields it needs in one round trip. In .NET that's usually Hot Chocolate. The costs are real: everything is a POST to one endpoint so HTTP caching mostly goes away, naive resolvers cause N+1 queries unless you use DataLoaders, and you need depth and cost limits so a client can't send a query that brings down the database. Messaging, with Azure Service Bus for commands or Event Grid for events, is different again: the sender doesn't wait and doesn't need the receiver to be up. That gives resilience and load levelling, but delivery is at least once, so consumers must be idempotent, and the UI has to cope with eventual consistency.
The mistake I see is picking one style for everything, like gRPC for a public API because it's faster, or synchronous HTTP chains across five services where an event would remove the coupling. In a typical Azure system I'd put REST, or GraphQL behind a BFF, at the edge, use gRPC or REST between services, and publish events through Service Bus. I choose the style per boundary, not per company."
| REST | gRPC | GraphQL | Messaging | |
|---|---|---|---|---|
| Contract | OpenAPI (optional) | .proto (required) |
Schema (required) | Message schema (often informal) |
| Transport | HTTP/1.1, 2, 3 | HTTP/2 (HTTP/3 possible) | HTTP, usually POST | AMQP, HTTPS to broker |
| Payload | JSON | Protobuf binary | JSON | Any (JSON, Avro) |
| Browser support | Native | gRPC-Web / transcoding | Native | Via backend only |
| HTTP caching | Yes (GET) | No | Hard (persisted queries help) | N/A |
| Streaming | SSE, chunked | Native, bidirectional | Subscriptions | Native (streams of messages) |
| Coupling | Synchronous, availability | Synchronous, contract | Synchronous, schema | Temporal decoupling |
| Failure model | Status codes, retries | Status codes, deadlines | Partial errors in 200 | Retries, dead-letter queues |
| .NET tooling | ASP.NET Core, OpenAPI | Grpc.AspNetCore | Hot Chocolate | Azure.Messaging.ServiceBus, MassTransit |
| Boundary | Typical choice | Why |
|---|---|---|
| Public / partner API | REST | Reach, caching, docs |
| Mobile and web BFF with varied screens | REST BFF or GraphQL | Fewer round trips, client-shaped data |
| Internal high-volume service calls | gRPC | Latency, contracts, streaming |
| "Something happened" notifications | Event Grid / Service Bus topics | Many subscribers, decoupled |
| Long-running or bursty work | Service Bus queue | Load levelling, retries, DLQ |
An [order platform] made a synchronous REST call chain (orders -> stock -> pricing -> notifications) for every checkout. When notifications slowed down, checkout p99 rose to [~4 s]. Publishing an OrderPlaced event to Service Bus for notifications, and moving stock and pricing to gRPC, cut checkout p99 to [~600 ms] and made notification outages invisible to customers.
Checks that the candidate can compare API styles on real trade-offs (performance, but also coupling, maintainability, operability and fit with the team's skills) and place each at the right boundary instead of following fashion.
Green flags
Red flags
Synchronous (REST, gRPC, GraphQL)
Caller ---request---> Callee caller blocks; callee must be up
<--response---
Asynchronous (messaging)
Producer --msg--> [Broker] --msg--> Consumer consumer can be down; work happens later
Synchronous chains multiply availability: five services at 99.9% each give roughly 99.5% for the chain. Messaging breaks that chain but introduces eventual consistency and at-least-once delivery.
Trade-offs: binary payloads are hard to inspect with curl; L4 load balancers pin long-lived HTTP/2 connections to one backend, so you need L7 balancing or client-side load balancing; browsers can't use raw gRPC.
query { order(id: 42) { id total customer { name } lines { sku product { name } } } }
-> resolver order(42)
-> resolver customer (1 query)
-> resolver lines (1 query)
-> resolver product x N (N queries unless batched by a DataLoader)
Hot Chocolate provides DataLoaders, projections onto EF Core IQueryable, cost analysis and depth limits. Persisted queries (allow-listed query hashes) restore some cacheability and stop arbitrary queries in production.
ghz.The same capability exposed three ways in one .NET 10 service: REST for partners, gRPC for internal callers, and an event for asynchronous consumers.
// Program.cs (.NET 10)
// Packages: Grpc.AspNetCore, Azure.Messaging.ServiceBus, Azure.Identity
using Azure.Identity;
using Azure.Messaging.ServiceBus;
using Grpc.Core;
using OrdersApi.Grpc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
builder.Services.AddSingleton(_ => new ServiceBusClient(builder.Configuration["ServiceBus:Namespace"], new DefaultAzureCredential()));
builder.Services.AddSingleton(sp => sp.GetRequiredService<ServiceBusClient>().CreateSender("order-events"));
var app = builder.Build();
// REST: public and partner clients, cacheable reads.
app.MapGet("/orders/{id:int}", (int id, HttpResponse res) =>
{
res.Headers.CacheControl = "private, max-age=15";
return Results.Ok(new OrderDto(id, "Pending", 120.50m));
});
// Command over REST that also publishes an event for async consumers (email, analytics).
app.MapPost("/orders/{id:int}/submission", async (int id, ServiceBusSender sender, CancellationToken ct) =>
{
// In production write this to an outbox in the same transaction as the state change.
var msg = new ServiceBusMessage(BinaryData.FromObjectAsJson(new OrderSubmitted(id, DateTimeOffset.UtcNow)))
{
MessageId = $"order-submitted-{id}", // stable id: duplicate detection can drop resends
Subject = nameof(OrderSubmitted)
};
await sender.SendMessageAsync(msg, ct);
return Results.Accepted($"/orders/{id}");
});
// gRPC: internal, typed, low-latency calls (base class generated from orders.proto).
app.MapGrpcService<OrdersGrpcService>();
app.Run();
public sealed record OrderDto(int Id, string Status, decimal Total);
public sealed record OrderSubmitted(int OrderId, DateTimeOffset At);
public sealed class OrdersGrpcService : Orders.OrdersBase
{
public override Task<OrderReply> GetOrder(GetOrderRequest request, ServerCallContext context) =>
Task.FromResult(new OrderReply { Id = request.Id, Status = "Pending" });
}
// Protos/orders.proto (in the .csproj: <Protobuf Include="Protos\orders.proto" GrpcServices="Server" />)
syntax = "proto3";
option csharp_namespace = "OrdersApi.Grpc";
service Orders { rpc GetOrder (GetOrderRequest) returns (OrderReply); }
message GetOrderRequest { int32 id = 1; }
message OrderReply { int32 id = 1; string status = 2; }
MessageIds sent within its window, and only on the send side. Instead: Make consumers idempotent: record processed message ids in an inbox table in the same transaction as the business change (unique key on message id + consumer), design handlers as upserts or state checks ("if already shipped, do nothing"), set stable MessageIds on send, and route poison messages to the dead-letter queue after max delivery count.The style matters less than the boundary it sits on. I choose based on who the clients are, whether the caller needs the answer now, and what the team can operate: gRPC with poor HTTP/2 load balancing, or GraphQL without cost limits, are worse than plain REST. I also keep the domain logic independent of the transport so a capability can be exposed as REST and gRPC (or later as an event) without rewriting it.
How I'd measure: per-boundary p95/p99 latency and payload sizes, the depth of synchronous call chains in distributed traces, dead-letter counts for messaging, and GraphQL query cost distributions.
| Style | When it fits | Cost | When not |
|---|---|---|---|
| REST | Public, partner, CRUD-ish, cacheable reads | Over/under-fetching, chattiness | Very high-volume internal calls |
| gRPC | Internal calls, streaming, polyglot typed contracts | HTTP/2 infra, debugging binary | Browsers and third parties |
| GraphQL | Many front ends with varied data needs | Caching, N+1, query governance | Simple APIs with one client |
| Messaging | Events, long work, load levelling, decoupling | Eventual consistency, idempotency, ops | Caller needs an immediate answer |
gRPC is a contract-first RPC framework. You define services and messages in a .proto file, and Grpc.Tools generates a C# base class for the server and a typed client at build time. Messages are serialised with Protocol Buffers, a compact binary format, and sent over HTTP/2, which gives multiplexed streams and trailers for the status. There are four call types: unary, server streaming, client streaming and bidirectional streaming. Every call should have a deadline, which flows to the server as a cancellation token. Compared with REST/JSON it is faster, smaller on the wire and strongly typed, with first-class streaming. But browsers can't call it directly, so you need gRPC-Web or JSON transcoding, and it is harder to debug and cache.
The trade-off: gRPC wins for internal service-to-service traffic; REST stays the default for public and browser APIs.
CQRS splits the model that changes state (commands) from the model that reads it (queries). It grows out of Meyer's CQS (a method either changes state or returns data), applied to whole models.
Select/AsNoTracking or Dapper.There are levels. Separate handlers on one database is cheap and often enough. Denormalised read tables updated in the same transaction stay consistent. A separate read store fed by events scales reads but is eventually consistent, so the UI needs read-your-writes or "processing" states.
CQRS doesn't need MediatR or event sourcing. It's overkill for CRUD where reads and writes have the same shape. The trade-off is optimised, simple models on each side against more moving parts and, at the top level, stale reads.
The dual-write problem: an order is saved in SQL Server and an OrderPlaced event is sent to Service Bus. Those are two systems with no shared transaction. If the publish fails after the commit, the event is lost. If you publish first and the commit fails, consumers act on an order that doesn't exist.
The outbox fixes this by writing the event as a row in an OutboxMessages table in the same EF Core transaction as the order. A relay (a BackgroundService polling with UPDLOCK, READPAST) publishes unprocessed rows and marks them ProcessedAt.
A crash between publish and mark means the row is sent again, so delivery is at-least-once. Consumers must be idempotent (an inbox), helped by setting MessageId to the outbox id for Service Bus duplicate detection. The trade-off is guaranteed publication against extra writes, latency, cleanup and a relay to monitor.
How to tell it (STAR)
**S:** At [company], checkout called stock, pricing and notifications synchronously, and every time the email provider slowed down, checkout p99 jumped to about four seconds. **T:** With a big sale [two weeks] away, I had to make checkout independent of non-critical services. **A:** I used the Application Insights application map to show notifications didn't need to finish before we responded, added a short timeout as a stop-gap, then moved notifications to an `OrderPlaced` event on a Service Bus topic via an outbox, with an idempotent consumer. I also moved stock and pricing to gRPC with deadlines. **R:** Checkout p99 dropped to [~600 ms], an email provider outage during the sale had no customer impact, and [no] duplicate emails were sent thanks to the idempotent consumer.
Last updated 23 Nov 2026.