categories.system-design Intermediate

Message Queue Use Cases and Technology Selection (Kafka vs RabbitMQ)

AI Practice

Message Queue (MQ)

Why Use a Message Queue?

  • Decoupling: Producer doesn't wait for consumer to finish
  • Load leveling: Buffer traffic spikes to prevent downstream service overload
  • Async processing: Time-consuming tasks (emails, reports) run in background
  • Reliable delivery: Failed consumers can retry

Kafka vs RabbitMQ

Feature Kafka RabbitMQ
Architecture Distributed log Traditional MQ broker
Throughput Very high (millions/sec) High (tens of thousands/sec)
Message retention Persistent log, replayable Deleted after consumption (default)
Ordering Guaranteed within a partition Guaranteed within a single queue
Use cases Data streaming, log collection, event sourcing Task queues, RPC callbacks

Common Patterns

  • Point-to-Point: Single consumer processes each message (competing consumers)
  • Pub/Sub: Multiple consumers subscribe to same topic; each gets a copy
  • Dead Letter Queue (DLQ): Failed messages go to DLQ for manual review

Interview bonus: Explain "at-least-once" vs "exactly-once" semantics and why true exactly-once is hard in distributed systems (Kafka Transactions is one solution).

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub