Lesson 13 of 18
22. Message Queues

Memory card and where the analogy breaks

3 min read+10 XP

The memory card (tear this page out)

#QuestionMemory code
22.1Producers and consumers?Leave the job on the board; whoever's free picks it up
22.2Why async?Do now what they must see; queue what can wait a moment
22.3Delivery guarantees?Ack first and maybe lose it; ack last and maybe repeat it; make repeats harmless
22.4Acks and visibility timeouts?Taken off the board while you work; put back if you don't finish
22.5Retries and DLQs?Try again with growing pauses; after a few, send it to the manager's desk
22.6Idempotent consumers?Stamp the passbook, so a second call pays nothing
22.7Ordering?Same key, same line, same clerk: order kept where it matters
22.8Backpressure?A queue turns a rush into a wait; backpressure stops the wait from growing forever
22.9Scaling consumers?Counters needed = customers per minute × minutes each
22.10Log vs queue?A queue hands out slips and bins them; a log keeps the ledger for every reader
22.11Delayed jobs?A token for later: when it's called, check it still needs doing

The whole chapter in one line: Queue what can wait, ack only after the work is done, make every consumer safe to run twice, keep order only per key, and watch the backlog.

Where the analogy breaks

  • A bank customer notices if they're served twice. A message doesn't: duplicates are silent unless the consumer checks.
  • A bank's tokens are gone at closing time. A log keeps every message for days, and readers can rewind and replay.
  • A clerk who faints is obvious. A stuck worker isn't: the broker only knows it didn't hear an ack in time.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz