Software → System Design
Message Queue
A system component that stores messages so producers and consumers can communicate asynchronously.
Motivation
Message queues solve the problem of coupling one part of a system directly to another. Instead of forcing a producer and consumer to be available at the same time, the queue stores work until it can be processed.
Where it fits
A message queue belongs in system design because it changes how services communicate, absorb load, retry failures, and process work asynchronously.
Mental model
The sender drops work into a durable buffer. One or more consumers later pull that work and process it at their own pace.
Subconcepts
Producer
The component that writes messages into a queue or stream.
Consumer
The component that reads messages from a queue or stream.
FIFO Queue
A queue discipline where the oldest message is processed first.
Dead Letter Queue
A queue used to isolate messages that cannot be processed successfully.
Common mistakes
- Assuming queues guarantee exactly-once processing.
- Forgetting retries, poison messages, and idempotency.
- Letting queues hide permanent downstream failures.
Related concepts
Publish-subscribe, backpressure, idempotency, asynchronous programming, and event-driven architecture.
Queue Depth
Queue Depth is the number of messages waiting to be processed. A rising queue depth can mean consumers are too slow, downstream systems are unhealthy, traffic has spiked, or retry behavior is amplifying load. Teams normally interpret it together with arrival rate, processing rate, message age, and error rate rather than treating one number as sufficient.