Message queues vs event streams: when to use a queue, pub/sub or a log like Kafka
When one part of a system needs to hand work to another without waiting, you reach for messaging. But "messaging" covers several different tools.
Work queues
- A producer adds jobs; one consumer takes each job and removes it.
- Great for background tasks: sending emails, resizing images, processing uploads.
- Built-in retries and dead-letter queues for jobs that keep failing.
- Examples: managed queue services, RabbitMQ, Redis-backed job libraries.
Pub/sub
- A message is published to a topic and every subscriber gets a copy.
- Good for fan-out: "order placed" triggers billing, email and analytics independently.
Event logs / streams
- Messages are appended to a durable, ordered log and kept for a retention period.
- Consumers track their own position and can replay history.
- Good for high-throughput event pipelines, audit trails and rebuilding derived data.
- Examples: Kafka and similar log-based systems.
Questions that help you choose
- Should each message be handled once, or by many independent consumers?
- Do you need to replay old events?
- Does order matter, and across what scope?
- How much throughput do you really need?
Common mistake
Adopting a streaming platform when a simple queue would do. Streams are powerful but bring more operational weight.
What do you reach for by default? Has anyone moved from a stream back to a plain queue because it was simpler?
Comments · 4
If I just need a background job, is a simple queue enough? Kafka sounds like overkill for my small app.
A simple queue is plenty for background jobs. Reach for a log like Kafka only when you need replay or many consumers reading the same stream.
We started with a managed queue and only added a log when we needed to replay events. Don't pre-optimize for scale you don't have.
Worth noting that "exactly once" delivery is mostly a design property, not a magic setting. Idempotent consumers save you.