Skip to the page

Design building blocks · mid

Message queue or Kafka

A queue gives each message to one consumer and removes it after the ack. A log such as Kafka keeps ordered events that many consumer groups read and replay. Pick by who needs to read the event.

The notes

What you must know

  • Queue (RabbitMQ, SQS): each message goes to one consumer and is removed after it is acknowledged. It has per-message acks, retries, delays and dead-letter queues. Good for distributing work, such as send this email.
  • Log (Kafka, Kinesis, Pulsar, Redpanda): an append-only, partitioned log kept for days. Each consumer group has its own offset, so many services read the same events and can replay.
  • For an order placed event read by five services, some needing replay: a Kafka topic keyed by order or customer id, one consumer group per service.
  • Order is kept within a partition only, and throughput is very high. SQS FIFO keeps order per message group.
  • Failures: queues have dead-letter queues built in. With classic Kafka consumers you build retry and dead-letter topics yourself, because one bad message blocks its partition.
  • Parallelism in Kafka is limited by the partition count.
  • Kafka 4.x runs only in KRaft mode; ZooKeeper was removed in 4.0 (March 2025).
  • Use idempotent consumers either way, because delivery can repeat.

The red pen

Common traps: mistake → fix

  • Mistake: Kafka needs ZooKeeper

    Fix: Kafka 4 runs only in KRaft mode.

  • Mistake: Kafka orders everything globally

    Fix: only within a partition.

  • Mistake: Use Kafka as a job queue without thought

    Fix: one slow message blocks a partition.

Easy to hard

Questions interviewers ask, easy to hard

  1. Queue or Kafka for order events? Why?
  2. How does ordering work in Kafka?
  3. How do you handle a poison message?
  4. When would you choose SQS over Kafka?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview