Message queues are like postal services for your data - they allow different parts of your system to communicate with each other by sending messages through a queue. This decouples the components of your system, allowing them to scale and evolve independently.
📤 Producer
➡️
📬 Message Queue
➡️
📥 Consumer
Overview
Asynchronous decoupling between producers and consumers using durable buffers.
Smooths spikes (load leveling), enables retries, and isolates failures.
When to use
Work is deferrable; user can receive eventual confirmation.
Burst traffic overwhelms synchronous backends.
Need fan-out, at-least-once delivery, or ordering by key/partition.
Trade-offs
Increased complexity: duplicates, ordering, and exactly-once illusions.
Patterns
Dead-letter queues for poison messages; retry with exponential backoff + jitter.
Outbox pattern to publish reliably from DB transactions.
Partition by key for ordering; idempotent consumers.