システムでは、コンポーネント(サービス、クライアント)がAPIと様々なプロトコル —— 同期通信(REST、gRPC)と非同期通信(メッセージング/キュー)—— を通じて通信します。コンポーネントがどのように通信するかを理解することは、複数の部品から構成されるシステムを設計するうえで基本的なことです。
同期通信(リクエスト/レスポンス)
The caller WAITS for a response (blocking):
REST (HTTP) → most common; resources over HTTP (JSON) → simple, ubiquitous, web-friendly
gRPC → high-performance RPC (binary, HTTP/2) → fast, typed; good for internal services
GraphQL → flexible queries (client requests exactly what it needs)
→ for: direct request/response where the caller needs an answer now
非同期通信(メッセージング)
The caller does NOT wait (decoupled, non-blocking):
MESSAGE QUEUES (RabbitMQ, SQS) → send a message; a consumer processes it later
EVENT STREAMING (Kafka) → publish events; consumers react
PUB/SUB → broadcast events to subscribers
→ for: decoupling, background work, handling spikes, event-driven systems
✓ resilience (queue buffers), scalability, decoupling ✗ more complexity, eventual consistency
