← Back to all articles

What Message Queues Solve: Async, Buffering, Decoupling

NetworkBeginner

Three values

ValueScenario
AsyncSend email, build reports; the main flow need not wait
Buffer peaksFlash sale spikes enter the queue, consumed at a steady rate
DecoupleServices talk via events, not direct calls

Typical shape

Producer to queue (durable) to consumer. The queue buffers in the middle; the producer can fail without losing work, and a slow consumer will not crush upstream.

Two caveats to settle

  1. Duplicate consumption: retries can deliver a message twice, so the consumer must be idempotent (dedup table, state machine);
  2. Ordering: one queue is usually ordered, but after sharding the same business key must route to the same shard to keep order.

Versus RPC

RPC is a synchronous "I need the result now" call; a queue is an asynchronous "handle it later" notice. Deduct stock on order via RPC, send the email via queue.