Message Queue

Messaging

Also known as: MQ, task queue

A message queue is a communication mechanism that enables asynchronous data exchange between services by storing messages in a queue until the receiving service is ready to process them.

Message queues decouple producers (services that send messages) from consumers (services that process them). The producer sends a message to the queue and moves on without waiting for a response. The consumer picks up messages at its own pace.

This decoupling provides several benefits: it absorbs traffic spikes (the queue buffers messages when consumers are slow), enables independent scaling of producers and consumers, and improves fault tolerance (messages persist in the queue if a consumer crashes).

Key design decisions include delivery guarantees (at-most-once, at-least-once, exactly-once), ordering guarantees, message persistence, and dead letter queues for failed messages.

Popular message queue implementations include RabbitMQ, Amazon SQS, and Redis (using its list or stream data structures). For higher-throughput event streaming, see Pub/Sub and systems like Apache Kafka.

Related Terms

Practice This Concept

Ready to design?

Practice using message queue in a real system design on Supaboard's interactive whiteboard.

Browse Challenges