Tech Interview RoomStudy guides

Microservices

How should microservices communicate: REST, gRPC or messaging? Choreography or orchestration?

Intermediate · 2 min read · Lesson 1 of 10 in Microservices

Synchronous request/response

  • REST over HTTP/JSON: universal, cacheable, easy to debug; good for public and CRUD-style APIs.
  • gRPC (HTTP/2 + Protobuf): binary, strongly typed contracts with code generation, streaming, lower latency; good for internal high-volume calls. Less browser-friendly.
  • Drawback: temporal coupling. The caller fails if the callee is down, and latency adds up along call chains. Requires timeouts, retries and circuit breakers.

Asynchronous messaging

  • Events (OrderPlaced) or commands (ReserveStock) via Kafka, RabbitMQ, SQS/SNS, Pub/Sub.
  • Decouples availability (the consumer can be down; the broker buffers), absorbs load spikes, enables fan-out to many consumers.
  • Costs: eventual consistency, harder debugging, duplicate and out-of-order delivery to handle, message schema evolution.

Rule of thumb

Use synchronous calls for queries where the user is waiting for an answer, and asynchronous events for state changes that other services react to. Avoid long synchronous chains (A → B → C → D).

Choreography vs orchestration

  • Choreography: each service reacts to events and publishes its own. No central coordinator, loose coupling; but the overall flow is implicit and hard to follow or change once there are many steps.
  • Orchestration: a coordinator (a saga orchestrator, Temporal, Camunda, AWS Step Functions) tells each service what to do and tracks state. The flow is explicit, visible and easier to handle failures and timeouts in, at the cost of a central component.
  • Choreography for simple flows with few steps; orchestration for complex business processes with compensation and timeouts.

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you version APIs and events without breaking consumers?

Prefer backward-compatible evolution: add optional fields, never remove or rename fields or change their meaning, and make consumers tolerant readers (ignore unknown fields). For breaking changes, run versions side by side (/v2/ path, or a new event type OrderPlacedV2), migrate consumers, then retire the old one. For events, use a schema registry (Avro/Protobuf with compatibility checks in CI).

When would you pick gRPC over REST?

For internal service-to-service calls with high throughput or low latency requirements, polyglot teams that benefit from generated clients and strict contracts, and streaming use cases. Keep REST (or a REST gateway in front of gRPC) for public APIs, browser clients and when HTTP caching and human readability matter.