Knowledge Guide
HomeSystem DesignKafka

Messaging patterns

In distributed systems, messaging patterns define how components communicate via asynchronous messages. Understanding these patterns is crucial for designing scalable and reliable systems. Below, we cover five key messaging patterns, each with its core idea, characteristics, and practical examples.

1. Point-to-Point (Direct Messaging)

In a point-to-point pattern, each message is delivered to exactly one consumer. A producer sends messages into a queue (or similar channel), and one of the consumers reading from that queue will receive each message. This ensures no two consumers process the same message.

2. Publish-Subscribe (Pub/Sub)

The publish-subscribe pattern delivers each message to all interested subscribers. A publisher sends messages to a topic (or exchange), and multiple subscribers receive a copy of each message. Publishers and subscribers are decoupled — the publisher doesn’t know who receives the message.

3. Request-Reply (Request-Response)

The request-reply pattern is a two-part message exchange: a requester sends a message and expects a response message in return. It’s analogous to a function call or API request, but implemented asynchronously through messaging. This pattern allows a form of synchronous interaction on top of an asynchronous system.

4. Fan-Out/Fan-In (Scatter-Gather)

Fan-Out/Fan-In (also known as Scatter-Gather) is a composite pattern where a message is scattered to multiple recipients in parallel (fan-out), and then the results are gathered back (fan-in). Essentially, one request triggers multiple parallel processes and an aggregator collects all the responses or outcomes.

5. Dead Letter Queue (DLQ)

A Dead Letter Queue is a safety net for messages that cannot be processed successfully. When a message continually fails processing (due to errors, format issues, or exceeding retry limits), it is moved to a special queue called the Dead Letter Queue instead of being lost or blocking the main queue. This pattern ensures problematic messages are isolated for later inspection or remediation.

🤖 Don't fully get this? Learn it with Claude

Stuck on Messaging patterns? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Messaging patterns** (System Design) and want to truly understand it. Explain Messaging patterns from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Messaging patterns** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Messaging patterns** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Messaging patterns** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes