Pub/Sub

Redis Pub/Sub (Publish/Subscribe) is a messaging paradigm within Redis that allows for message broadcasting through channels. This feature enables the development of real-time messaging applications by allowing publishers to send messages to an unspecified number of subscribers asynchronously.

Notifications and Alerts

For applications that need to notify users of events in real time (such as social media notifications, stock alerts, or emergency alerts), Redis Pub/Sub provides a lightweight and fast way to distribute messages.

Live Data Updates

In dashboard applications or live data feeds (such as sports scores, financial market data, or IoT sensor data), Redis Pub/Sub can push updates to clients as soon as new data is available.

Decoupling Microservices

Redis Pub/Sub can be a messaging backbone to decouple microservices architectures. Services can publish events or messages without knowing the details of which services are subscribed to those events. This promotes loose coupling, making the system more scalable and easier to maintain.

Limitations

1. Message Persistence

2. Lack of Delivery Acknowledgment

3. Filtering and Routing - Lacks advanced filtering other than basic * (asterisk)

4. Resource Utilization

Because Redis operates in memory, high volumes of messages or large numbers of subscribers can lead to significant memory and network bandwidth usage. Planning and monitoring resource utilization becomes critical as the messaging system grows in scale.

Client 1

subscribe class_update_channel 
subscribe school_update_channel

Client 2

psubscribe *_channel bigdata_class_mates

Producer

publish class_update_channel "Hello class"
publish school_update_channel "who is graduating this summer?"
publish glassboro_channel "welcome to Glassboro"

Last updated