Home/Labs/Sync vs Async Chain
All 280 Labs
INTERACTIVE LAB📡

Inter-Service Communication Lab (Interactive)

Run a request through REST or gRPC hops, then flip to Kafka and compare latency, availability, and propagation. Synchronous chains sum every hop latency and multiply availability; asynchronous chains return after a broker ack and let consumers proceed independently.

Sync RPC Waterfall vs Async Event Stream

Same checkout, four collaborators. Switch paradigms and see latency summation and availability multiplication change.

Client-visible path (blocking waterfall)

End-to-end response time92 ms
Transaction availability99.601%
Downtime / year35.0 h

T_total = Σ Tᵢ = 92ms and A = 99.9%^4. Every hop is a chance the whole user transaction dies.

Eventual-consistency trade

Async fan-out fully propagated after~69 ms
Availability gained vs sync chain+0.30%
10x traffic spike absorbed bynothing — callers block

Production rule: gRPC synchronously for reads that need an immediate answer (JWT validation, fraud score), Kafka asynchronously for mutations and side effects (OrderCreated events). The hybrid checkout acks in ~30ms while four consumers reconcile eventually.

How It Works Under the Hood

Synchronous HTTP/gRPC couples callers temporally: total latency is the sum of hops, availability is the product of hops, and every failure path needs timeout, retry, and circuit-breaker logic. Asynchronous messaging through Kafka converts the chain into a relay race: the producer pays only for a durable broker acknowledgment, often under 10 ms, and slow consumers buffer behind it instead of failing the user request. The price is eventual consistency, event-schema versioning, and consumers that must be idempotent because at-least-once delivery duplicates messages.

Core Architectural Principles

  • Sync mode sums per-hop latency across the chain; async mode charges only broker ack plus fan-out.
  • Availability composes as A^N for sync calls but stays A^1 for the produce-and-ack path.
  • REST at 25 ms and gRPC at 3 ms per hop change the crossover where async clearly wins.
Interview Round Script

For "when async?" answer with three triggers: work can happen later, you need burst absorption, or you want fan-out to many consumers. Then show the trade side: sync is right when the user is blocked on the answer and you need immediate validation. Name the async responsibilities you take on: idempotent consumers and a versioned event schema registry.

Key Trade-Offs

Async buys latency isolation and fan-out at the cost of eventual consistency; sync gives an immediate answer with multiplied failure coupling.

Related Curriculum Chapter

Inter-Service Communication: Synchronous vs Asynchronous Protocols

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs