APIs & Backend interview question

Why and when would you use a message queue?

Short answer

A message queue decouples producers from consumers: producers publish work and move on, and consumers process it at their own pace. Queues absorb traffic spikes, allow retries and enable asynchronous workflows such as emails, video processing or order fulfilment. The trade-offs are eventual consistency, duplicate delivery and the need for idempotent consumers.

Key concepts

  • At-least-once delivery means consumers must be idempotent.
  • Dead-letter queues capture messages that repeatedly fail.
  • Ordering is often guaranteed only within a partition or group.
  • Queues distribute work; logs such as Kafka also let consumers replay history.

How to answer it in an interview

  • Describe how you make a consumer idempotent with a processed-message key.
  • Mention the outbox pattern for publishing events reliably with a database write.

Walk into your next interview prepared

Start free, install the Windows app and run a practice session today.