Skip to content
Communication Between Services

Lesson 10 of 10 · 16 min

x
10/10

Lesson position in the course — not completion. Use Mark Complete to track finished lessons (saved in this browser).

Choosing the Right Communication Style

No single protocol fits every interaction. Use synchronous REST or gRPC when the caller needs an immediate answer and the operation is short-lived — "Does this user exist?" or "What is the current stock level?" Use async messaging when the caller can fire-and-forget, when you need to absorb traffic spikes, or when multiple services should react to the same event.

A typical production system combines both: synchronous calls for read-heavy, latency-sensitive paths; events and queues for writes, notifications, and workflows. Add an API Gateway at the edge, service discovery behind it, resilience patterns on every outbound call, and sagas for multi-step business operations. Start simple — direct REST between two services — and add complexity only when measurement proves you need it.

Check your understanding

  • Sync for which kind of question?Show answer

    Answer

    Short reads/commands that need an immediate answer (stock check, user exists).
  • Async for which kind of work?Show answer

    Answer

    Side effects, notifications, and multi-step workflows that can proceed without blocking the caller.
  • What should you add on every outbound call?Show answer

    Answer

    Timeouts and a resilience policy (retries/circuit breaker) sized to the dependency.
Previous

Progress is saved in this browser.

Finish Course