Question presented to candidate:
"Explain the publish-subscribe pattern. How is it different from just calling the other services, or from a work queue? And what changes when the broker is Redis Pub/Sub versus something like Kafka?"
What a strong answer should cover:
Publishers send messages to a topic without knowing who listens; the broker delivers a copy to every subscriber (fan-out), so producers and consumers are decoupled in identity, number and often time
The contrast with a point-to-point queue, where each message goes to one consumer, and how consumer groups combine both (fan-out across groups, load sharing within a group)
Ephemeral subscriptions (Redis Pub/Sub: only connected subscribers receive, at-most-once) versus durable ones (a retained log with per-subscriber offsets: late or offline subscribers catch up)
Delivery guarantees: durable systems are usually at-least-once, so subscribers must be idempotent; ordering is typically per partition or per key, not global
Costs: harder to trace a flow, schema evolution of events, and no reply path β pub/sub is for notifications, not for questions that need an answer
Code / implementation expected: Optional β the concepts matter most; the example builds an ephemeral channel and a durable partitioned log side by side.
pub-sub
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Beginners to system design who have written services that call each other; no messaging background assumed.
Difficulty: Medium
Verified with: Node 22.22 and Python 3.12 (both print identical output). Redis and Kafka behaviour is cited from their documentation.
How to read this doc: Each idea is explained in plain language first, then tagged with π Interview term: so you also learn the words an interviewer expects. Behaviour claims come from the example; the Verified section quotes the full output.
1. Why This Even Matters β A Story First
A bakery takes an order. Without pub/sub, the cashier has to walk to the kitchen and tell the baker, then phone the delivery driver, then update the loyalty-points book, then tell the accountant. Every new department means the cashier learns a new step, and if the accountant is at lunch, the cashier waits.
The solution is hidden so you can try first
11 min read Β· 9 sections
4
Read the code
Pub/sub two ways: an ephemeral channel vs a durable log with consumer groups and redelivery