Skip to content
RED SAGSkills
mediumBackend Developer interview question

When would you choose Kafka and when RabbitMQ for messaging between services?

What the interviewer wants to hear

  • Kafka is a durable, partitioned log that consumers read at their own offset
  • RabbitMQ is a broker that routes messages to queues and deletes them after ack
  • Kafka suits event streaming, high throughput, replay and many consumer groups
  • RabbitMQ suits task queues, flexible routing, per-message acks and priorities
  • Both give at-least-once delivery, so consumers must be idempotent

Model answer

They model messaging differently. Kafka is a distributed append-only log split into partitions. Messages stay for a retention period, and each consumer group tracks its own offset, so many independent services can read the same events and replay history. Ordering is kept per partition, and throughput is very high. I pick Kafka for event streaming, like order events consumed by billing, analytics and search, or for change data capture. RabbitMQ is a traditional broker: producers publish to exchanges, which route messages into queues, and a message is removed once a consumer acks it. It offers flexible routing, per-message acknowledgement, delayed retries and priorities, which makes it great for work queues like sending emails or resizing images. Both are usually at-least-once, so consumers must be idempotent. For simple needs, a managed queue like SQS can be enough.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Backend Developer questions