← System Design learning path
System Design · Module 6 of 10

Messaging and asynchronous processing

Decouple services with queues and events.

📖 Key ideas

  1. Message queues (RabbitMQ, SQS) hold tasks for workers.
  2. Event streams (Kafka) publish events to many consumers.
  3. Async processing handles slow tasks (emails, video encoding) in the background.
  4. Queues smooth traffic spikes.
  5. Design for retries and idempotency.
💡 Real-life example: A message queue is a restaurant ticket rail: orders wait their turn instead of overwhelming the cook.
Message queueBuffer of tasks for workers
Event streamOrdered log of events
Producer/consumerSender and receiver of messages
IdempotencySafe to process twice