في النظام، تتواصل المكونات (الخدمات، العملاء) من خلال APIs والبروتوكولات المختلفة — المتزامنة (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
