DEV Community

Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on • Edited on

Redis Pub/Sub vs Redis Streams: A Dev-Friendly Comparison

Hello, I'm Maneshwar. I'm working on FreeDevTools online currently building **one place for all dev tools, cheat codes, and TLDRs* — a free, open-source hub where developers can quickly find and use tools without any hassle of searching all over the internet.

Redis Pub/Sub vs Redis Streams: A Developer-Friendly Comparison

Redis has two powerful messaging mechanisms: Pub/Sub and Streams.

Both cater to specific needs, and understanding the difference can help you make the right choice for your use case.

Let’s break it down, developer-style.

Feature-by-Feature Breakdown

| Feature | Redis Pub/Sub

| Redis Streams |
|-----------------------|--------------------------------------------------|------------------------------------------------|
| Data Structure | Publish/subscribe mechanism | Append-only logs |
| Message Persistence | No message persistence by default | Messages are persisted in a stream |
| Message History | No message history is maintained | Message history is stored in the stream |
| Message Filtering | All messages are received by subscribers | Subscribers can filter by pattern or consumer groups |
| Message Delivery | At-least-once delivery semantics | Exactly-once delivery semantics |
| Consumer Groups | Not supported | Supported for multiple consumers |
| Scalability | Limited scalability | Scales better for large numbers of consumers |
| Message Retention | No built-in message retention | Configurable message retention |
| Use Cases | Real-time notifications | Event sourcing |


What Does This Mean for You?

Redis Pub/Sub

  • Good for: Real-time notifications, chat apps, or any use case where speed and simplicity are key.
  • Think of it like: A group chat where everyone hears what’s said, but once it’s said, it’s gone forever.

Redis Streams

  • Good for: Event sourcing, durable message queues, and systems requiring replayable logs or advanced processing.
  • Think of it like: A detailed logbook where every entry is stored and can be read whenever needed.


TL;DR

Redis Pub/Sub or Redis Streams?

The answer depends on your use case.

For real-time notifications, go with Pub/Sub. For persistence and scalability, Redis Streams is your best bet.

FreeDevTools

I’ve been building FreeDevTools.

A collection of UI/UX-focused tools crafted to simplify workflows, save time, and reduce friction in searching tools/materials.

Any feedback or contributors are welcome!

It’s online, open-source, and ready for anyone to use.

👉 Check it out: FreeDevTools
⭐ Star it on GitHub: freedevtools

Let’s make it even better together.

Top comments (3)

Collapse
 
kamalhinduja profile image
Kamal Hinduja

Great Explanation.

Collapse
 
lovestaco profile image
Athreya aka Maneshwar

Thanks :)

Collapse
 
imthedeveloper profile image
ImTheDeveloper

What's the downside to using streams Vs pub sub. It feels like you can almost use it as a queue as well if you force some concurrency in processing limit.

From what I've read you can set a limit on the stream length which actually means you can have a small level of durability or large. It just seems to offer lots of benefits.