Message Queues & Event-Driven Architecture

Difficulty
Importance

The problem

Services that call each other directly become tightly coupled — if one is slow or down, callers are blocked or fail too — and scaling a direct call chain means scaling every link in it together. Message queues decouple producers from consumers in both time and failure, letting each scale and fail independently.

Why now

Background jobs and queues already introduced a queue between a request handler and a worker on one system; this topic generalizes that exact pattern across service boundaries, turning it into an architectural style rather than a single feature, and it relies on the same durable, ordered delivery guarantee already established.

Mental model

In a direct call, the caller waits and fails if the callee is unavailable — tight coupling in both time and failure. A message queue breaks that coupling: a producer publishes an event and moves on, a consumer picks it up whenever it's ready, and if the consumer is temporarily down, the message just waits in the queue instead of the producer failing. Event-driven architecture is building a whole system around that decoupled, asynchronous flow instead of direct service-to-service calls.

Requires

Unlocks

Used in

Projects

  • Build a small event-driven system where a producer publishes 'order created' events and two independent consumers (inventory, email) react to them without knowing about each other
  • Simulate one consumer being offline for a period and confirm messages queue up and are processed once it returns, without the producer noticing or failing

Examples

  • An e-commerce order triggers an 'order placed' event; inventory, shipping, and analytics services each consume it independently, and adding a fourth consumer requires zero changes to the producer
  • If the email service goes down for ten minutes, queued 'send confirmation' messages simply wait and get processed once it's back, instead of the order failing

Resources

Mastery checklist