CodePark/ questions / Message queues & async work
START PRACTICINGPRACTICE
Backend question · System design & architecture › Message queues & async work

Compare Kafka, RabbitMQ and BullMQ. When would you choose each for a Node backend?

Choose Kafka for event streams, RabbitMQ for routing tasks between services, and BullMQ for background jobs inside a Node app.

Kafka is a distributed, partitioned, append-only log. Append-only means new messages are only added at the end. Kafka keeps messages for a configured time or size, whether or not anyone has consumed them. So several consumer groups can read the same topic independently. They can also replay from an earlier offset (position in the log). Kafka guarantees order only inside one partition. Choose it for:

  • high-throughput event streams
  • event-driven systems with many subscribers
  • cases where you need to replay old events

RabbitMQ is a message broker. Producers publish messages to exchanges. Exchanges route messages to queues by binding rules: direct, topic, fanout or headers. Consumers acknowledge each message, and then RabbitMQ removes it. Choose it for task distribution and flexible routing between services.

BullMQ is a Node library that builds a job queue on Redis. It supports:

  • delayed jobs
  • retries with backoff (growing waits between tries)
  • priorities
  • repeatable jobs
  • rate limiting

Choose it for background jobs inside a Node system, like sending emails or processing images. It fits when you already run Redis and do not need streaming across different languages.

  • Kafka is a partitioned log with retention, replay and consumer groups.
  • Kafka guarantees order only within one partition.
  • RabbitMQ routes messages from exchanges to queues, and consumers acknowledge each message.
  • BullMQ is a Node job queue on Redis with delays and retries.
  • Pick by need: Kafka for streaming, RabbitMQ for routing, BullMQ for background jobs.