Skip to content
Ameen Abozaid
MID-024

Communication models

  • 6 Lessons
  • 2.5 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Synchronous vs asynchronous
  • REST vs gRPC
  • request/reply

Learn first

2.5 h of practice (estimate)

Learning outcomes

  1. Compare synchronous request/response with asynchronous messaging for coupling, latency, and failure.
  2. Compare REST and gRPC (contracts, performance, tooling, browser support).
  3. Implement a gRPC service and client in Spring.
  4. Choose a communication style for each interaction in a system.

Lessons

  1. 01Sync vs async
  2. 02Temporal coupling
  3. 03REST vs gRPC
  4. 04gRPC and Protocol Buffers
  5. 05Request/reply over messaging
  6. 06Demo: the same call in REST and gRPC

Lab and exercises

Lab

MID-024-LAB1 · Interaction map

Outcomes: 1–4 · Time: ~2.5 h

  1. List every Shop interaction (place order, check stock, charge payment, send email, update search, and others).
  2. Mark each sync or async and justify using coupling, latency, and failure impact.
  3. Implement inventory's stock check as a gRPC service and a client in orders with a deadline.
  4. Test behavior when inventory is down.

Acceptance: interaction map plus working gRPC call.

Exercises (assessment: interaction-design review; five exercises)

IDOutcomeTask
MID-024-EX011Explain how an outage of inventory affects orders in a sync design and in an async design.
MID-024-EX021Compute the availability of a chain of four services each at 99.9%.
MID-024-EX032Make a REST vs gRPC table with contract, performance, tooling, and browser support for a public and an internal API.
MID-024-EX043Write a .proto for GetProduct and ListProducts (server streaming) and add a field without breaking clients.
MID-024-EX054Choose and justify a style for: price lookup at checkout, order confirmation email, stock decrement after payment, search index update.
Show solutions
  • EX01 Sync: orders fails or must handle errors immediately. Async: orders accepts the request and the stock step completes when inventory returns; the user sees a pending state.
  • EX02 About 0.999^4 = 0.996, so about 99.6%.
  • EX03 Public: REST (browser support, curl, OpenAPI). Internal: gRPC (strict contract, binary, streaming, generated clients).
  • EX04 Add optional string description = 5; with a new number, never reusing existing ones; keep rpc ListProducts (Query) returns (stream Product);.
  • EX05 Price lookup: sync. Email: async. Stock decrement: async event or saga step. Search index: async event. Justify by whether the caller needs the answer now.

Quiz

Outcomes: O1 sync vs async · O2 REST vs gRPC · O3 gRPC in Spring · O4 choose a style.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1Synchronous calls couple services by:O1
  2. 2Async messaging mainly helps with:O1
  3. 3A five-service synchronous chain is risky because:O1
  4. 4gRPC typically uses:O2
  5. 5Which is true about browsers and gRPC?O2
  6. 6Protocol Buffers fields are identified on the wire by:O3
  7. 7A safe, backward-compatible change to a message is:O3
  8. 8Every gRPC client call should have:O3
  9. 9A price lookup needed to render checkout should be:O4
  10. 10In request/reply over messaging, the reply is matched with the request by:O4

Practical part

Five exercises MID-024-EX01 to EX05 plus the lab. Pass: at least four exercises correct, an interaction map with justifications, and a working gRPC stock check with a deadline.

Common mistakes

Synchronous call chains five services deep; async used for queries that need an immediate answer.

Assessment

Interaction-design review.

Career relevance

Integration patterns (ARC-024).

Type to search levels, phases, modules and lessons.