advanced

Sync HTTP and gRPC

Use synchronous APIs for request-time decisions while budgeting latency, retries, timeout propagation, and cascading failure risk.

Synchronous RPC fits request-time decisions: authorize user, fetch price, reserve inventory before responding. HTTP/JSON is ubiquitous; gRPC adds typed contracts, streaming, and lower overhead on internal networks.

The trade-off is simplicity and debuggability versus latency chains and cascading failure when dependencies slow down. Budget end-to-end latency per hop; propagate deadlines; avoid deep synchronous graphs.

On interviews: compare REST versus gRPC for internal calls; explain timeout propagation and why retries on POST need idempotency.

Common pitfalls: unbounded fan-out synchronously; no deadline context; retry storms on 500 errors; treating gRPC as magic without observability.

Checklist:

  • Set per-hop timeouts from user-facing SLO.
  • Propagate trace and deadline metadata.
  • Limit synchronous call depth and fan-out.
  • Retry only safe, idempotent operations.